From 23d2a8a23c72a42d597a59722c5421f161c0f577 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotowicz Date: Tue, 11 Aug 2020 12:49:47 +0200 Subject: [PATCH] Gate attribute stringification on bug detection logic (IE<=9 does not stringify attributes), instead of Trusted Types feature flag. Added fixture tests for the logic. For attributes undergoing sanitizeURL, the value is stringified in sanitizeURL function, unless enableTrustedTypesIntegration is true and the value is and immutable TrustedScriptURL value. This ascertains that objects with custom toString() function cannot be used to bypass the sanitization (now that DOMPropertyOperations don't stringify on their own). Fixes #19587. --- fixtures/dom/src/components/Header.js | 3 + .../AttributeStringificationTestCase.js | 36 +++++++++ .../attribute-stringification/index.js | 28 +++++++ fixtures/dom/src/polyfills.js | 1 + .../src/client/DOMPropertyOperations.js | 39 +++++++--- .../__tests__/trustedTypes-test.internal.js | 73 ++++++++++++++++++- packages/react-dom/src/shared/sanitizeURL.js | 16 +++- 7 files changed, 182 insertions(+), 14 deletions(-) create mode 100644 fixtures/dom/src/components/fixtures/attribute-stringification/AttributeStringificationTestCase.js create mode 100644 fixtures/dom/src/components/fixtures/attribute-stringification/index.js diff --git a/fixtures/dom/src/components/Header.js b/fixtures/dom/src/components/Header.js index fe9709af00318..9e0c24e41e170 100644 --- a/fixtures/dom/src/components/Header.js +++ b/fixtures/dom/src/components/Header.js @@ -89,6 +89,9 @@ class Header extends React.Component { +