fix(35): WR-01 strip whitespace before the list, meta, CSS and comment scheme checks
Single-URL attributes removed ASCII whitespace and control characters before looking for a scheme, the list-valued, meta content, style and comment checks did not, so values="java	script:..." and a tab-split meta refresh passed. The stripping is factored out as stripURLSpace and used by every scheme check.
This commit is contained in:
@@ -78,6 +78,13 @@ func TestURLSchemeCheck(t *testing.T) {
|
||||
{"xmp_href", `<xmp><a href="javascript:alert(1)">x</a></xmp>`, `href="javascript:alert(1)"`, schemeMsg},
|
||||
{"self_closing_style", `<style/><a href="javascript:alert(1)">x</a>`, `javascript:alert(1)`, schemeMsg},
|
||||
{"conditional_comment_handler", `<!--[if mso]><img src="x.png" onerror="alert(1)"><![endif]-->`, `onerror="alert(1)"`, "event handlers"},
|
||||
// Whitespace-split schemes in list, meta, CSS and comment values
|
||||
// (WR-01).
|
||||
{"values_tab_split", `<svg><a><animate attributeName="href" values="java	script:alert(1)"/><text>x</text></a></svg>`, `values="java	script:alert(1)"`, schemeMsg},
|
||||
{"meta_refresh_tab_split", `<meta http-equiv="refresh" content="0;url=java	script:alert(1)">`, `url=java	script:alert(1)`, schemeMsg},
|
||||
{"srcset_newline_split", `<img src="a.png" srcset="a.png 1x, java script:x 2x">`, `java script:x 2x`, schemeMsg},
|
||||
{"style_tab_split", `<div style="background:url(java	script:x)">x</div>`, `url(java	script:x)`, schemeMsg},
|
||||
{"style_element_space_split", "<style>td { background: url(java\tscript:x); }</style>", "url(java script:x)", schemeMsg},
|
||||
{"nested_too_deep", strings.Repeat("<noscript>", maxMarkupDepth+2) + "x", "<noscript>", "too deeply"},
|
||||
}
|
||||
for _, tc := range refuses {
|
||||
|
||||
Reference in New Issue
Block a user