Skip to content

馃悰 Block spaced !important in inline style sanitizer - #40536

Merged
powerivq merged 3 commits into
ampproject:mainfrom
madib06ops:inline-style-spaced-important
Aug 13, 2026
Merged

馃悰 Block spaced !important in inline style sanitizer#40536
powerivq merged 3 commits into
ampproject:mainfrom
madib06ops:inline-style-spaced-important

Conversation

@madib06ops

Copy link
Copy Markdown
Contributor

INVALID_INLINE_STYLE_REGEX is the only CSS-level check isValidAttr runs on an inline style attribute, and its !important token assumes no whitespace between the ! and important. CSS permits whitespace there and browsers honor color:red ! important as an important declaration, so an author or template value like color:blue ! important slips past the denylist and lands in the DOM after reaching the purifier through amp-mustache, amp-bind [style], or amp-list, letting it override AMP protective !important rules. Relax the token to !\s*important so the spaced and tabbed forms are caught while valid styles and the existing position rules stay unchanged.

@powerivq
powerivq merged commit dd2f6b4 into ampproject:main Aug 13, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants