diff --git a/src/purifier/sanitation.js b/src/purifier/sanitation.js index 9c65b2614858..44e89fb4481c 100644 --- a/src/purifier/sanitation.js +++ b/src/purifier/sanitation.js @@ -348,7 +348,7 @@ const EMAIL_DENYLISTED_TAG_SPECIFIC_ATTRS = Object.freeze({ * @const {!RegExp} */ const INVALID_INLINE_STYLE_REGEX = - /!important|position\s*:\s*fixed|position\s*:\s*sticky/i; + /!\s*important|position\s*:\s*fixed|position\s*:\s*sticky/i; /** * Whether the attribute/value is valid. diff --git a/test/unit/test-purifier.js b/test/unit/test-purifier.js index 7b88bc1c0c1e..f0b80e21a52d 100644 --- a/test/unit/test-purifier.js +++ b/test/unit/test-purifier.js @@ -592,6 +592,14 @@ describes.sandboxed('DOMPurify-based', {}, (env) => { }); }); + it('should ignore styles containing spaced `! important`', () => { + allowConsoleError(() => { + expect( + purify('