Skip to content

Commit a76cdd2

Browse files
committed
fix($sanitize): remove inline style from sanitization Firefox bug detection
Inserting a `style` tag causes a CSP violation when using a strict CSP that doesn't allow inline styles. The `style` tag doesn't seem relevant for the Firefox bug detection, and can be replaced with a `span`, see issue angular#16463 for more details. The related unit test in `sanitizeSpec.js`, "should not allow JavaScript hidden in badly formed HTML to get through sanitization (Firefox bug)", is left untouched and still uses `style` to assert that the behavior hasn't changed in the original scenario. Fixes angular#16463.
1 parent 418355f commit a76cdd2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ngSanitize/sanitize.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ function $SanitizeProvider() {
441441
return getInertBodyElement_XHR;
442442
} else {
443443
// Check for the Firefox bug - which prevents the inner img JS from being sanitized
444-
inertBodyElement.innerHTML = '<svg><p><style><img src="</style><img src=x onerror=alert(1)//">';
444+
inertBodyElement.innerHTML = '<svg><p><span><img src="</span><img src=x onerror=alert(1)//">';
445445
if (inertBodyElement.querySelector('svg img')) {
446446
return getInertBodyElement_DOMParser;
447447
} else {

0 commit comments

Comments
 (0)