jquery/src
Michał Gołębiowski-Owczarek de5398a6ad
Core:Manipulation: Add basic TrustedHTML support
This ensures HTML wrapped in TrustedHTML can be used as an input to jQuery
manipulation methods in a way that doesn't violate the
`require-trusted-types-for` Content Security Policy directive.
This commit builds on previous work needed for trusted types support, including
gh-4642 and gh-4724.

One restriction is that while any TrustedHTML wrapper should work as input
for jQuery methods like `.html()` or `.append()`, for passing directly to the
`jQuery` factory the string must start with `<` and end with `>`; no trailing
or leading whitespaces are allowed. This is necessary as we cannot parse out
a part of the input for further construction; that would violate the CSP rule -
and that's what's done to HTML input not matching these constraints.

No trusted types API is used explicitly in source; the majority of the work is
ensuring we don't pass the input converted to string to APIs that would
eventually assign it to `innerHTML`. This extra cautiousness is caused by the
API being Blink-only, at least for now.

The ban on passing strings to `innerHTML` means support tests relying on such
assignments are impossible. We don't currently have such tests on the `main`
branch but we used to have many of them in the 3.x & older lines. If there's
a need to re-add such a test, we'll need an escape hatch to skip them for apps
needing CSP-enforced TrustedHTML.

See https://web.dev/trusted-types/ for more information about TrustedHTML.

Fixes gh-4409
Closes gh-4927
Ref gh-4642
Ref gh-4724
2021-09-30 16:00:24 +02:00
..
ajax Ajax: Don't auto-execute scripts unless dataType provided 2021-01-26 15:58:29 +01:00
attributes Core: Drop support for Edge Legacy (i.e. non-Chromium Microsoft Edge) 2020-09-22 17:49:28 +02:00
core Core:Manipulation: Add basic TrustedHTML support 2021-09-30 16:00:24 +02:00
css CSS: Trim whitespace surrounding CSS Custom Properties values 2021-09-23 13:35:18 +02:00
data Build: Update eslint-config-jquery, fix linting violations 2020-05-18 22:25:49 +02:00
deferred Core: Migrate from AMD to ES modules 🎉 2019-11-18 21:15:03 +01:00
deprecated Build: Correct code indentations based on jQuery Style Guide 2020-05-05 10:49:27 +02:00
effects Build: Correct code indentations based on jQuery Style Guide 2020-05-05 10:49:27 +02:00
event Build:Event: Make sure all source modules' exports are used (#4648) 2020-06-02 13:45:08 +02:00
exports Core: Migrate from AMD to ES modules 🎉 2019-11-18 21:15:03 +01:00
manipulation Core:Manipulation: Add basic TrustedHTML support 2021-09-30 16:00:24 +02:00
queue Core: Migrate from AMD to ES modules 🎉 2019-11-18 21:15:03 +01:00
selector CSS: Trim whitespace surrounding CSS Custom Properties values 2021-09-23 13:35:18 +02:00
traversing Build: Update eslint-config-jquery, fix linting violations 2020-05-18 22:25:49 +02:00
var CSS: Trim whitespace surrounding CSS Custom Properties values 2021-09-23 13:35:18 +02:00
.eslintrc.json Build: Make the import/no-unused-modules ESLint rule work in WebStorm 2020-09-02 17:24:55 +02:00
ajax.js Core: Drop support for Edge Legacy (i.e. non-Chromium Microsoft Edge) 2020-09-22 17:49:28 +02:00
attributes.js Core: Migrate from AMD to ES modules 🎉 2019-11-18 21:15:03 +01:00
callbacks.js Core: Migrate from AMD to ES modules 🎉 2019-11-18 21:15:03 +01:00
core.js Core:Manipulation: Add basic TrustedHTML support 2021-09-30 16:00:24 +02:00
css.js CSS: Trim whitespace surrounding CSS Custom Properties values 2021-09-23 13:35:18 +02:00
data.js Core: Migrate from AMD to ES modules 🎉 2019-11-18 21:15:03 +01:00
deferred.js Deferred: Rename master to primary 2021-01-12 20:56:51 +01:00
deprecated.js Deprecated: Remove jQuery.trim 2020-05-18 23:20:38 +02:00
dimensions.js Build: Correct code indentations based on jQuery Style Guide 2020-05-05 10:49:27 +02:00
effects.js Core: Drop support for Edge Legacy (i.e. non-Chromium Microsoft Edge) 2020-09-22 17:49:28 +02:00
event.js Event: Don't break focus triggering after .on(focus).off(focus) 2021-05-10 18:59:14 +02:00
jquery.js Build:Event: Make sure all source modules' exports are used (#4648) 2020-06-02 13:45:08 +02:00
manipulation.js Manipulation: Don't remove HTML comments from scripts 2021-07-19 19:04:23 +02:00
offset.js Core: Migrate from AMD to ES modules 🎉 2019-11-18 21:15:03 +01:00
queue.js Core: Migrate from AMD to ES modules 🎉 2019-11-18 21:15:03 +01:00
selector.js CSS: Trim whitespace surrounding CSS Custom Properties values 2021-09-23 13:35:18 +02:00
serialize.js Build: Correct code indentations based on jQuery Style Guide 2020-05-05 10:49:27 +02:00
traversing.js Core: Migrate from AMD to ES modules 🎉 2019-11-18 21:15:03 +01:00
wrap.js Core: Migrate from AMD to ES modules 🎉 2019-11-18 21:15:03 +01:00
wrapper.js Docs: Change JS Foundation mentions to OpenJS Foundation 2020-05-18 18:41:32 +02:00