Don't allow atttributes whose namespace starts with `data-`.
authorC. Scott Ananian <cscott@cscott.net>
Tue, 22 Dec 2015 23:24:33 +0000 (18:24 -0500)
committerC. Scott Ananian <cscott@cscott.net>
Tue, 22 Dec 2015 23:35:09 +0000 (18:35 -0500)
Change-Id: Ia76c74941b09e3ad131fe2fee31ffec3e540170b

includes/Sanitizer.php
tests/parser/parserTests.txt

index 4fc775f..5242856 100644 (file)
@@ -756,7 +756,9 @@ class Sanitizer {
                        # * data-mw-<name here> is reserved for extensions (or core) if
                        #   they need to communicate some data to the client and want to be
                        #   sure that it isn't coming from an untrusted user.
-                       if ( !preg_match( '/^data-(?!ooui|mw|parsoid)/i', $attribute )
+                       # * Ensure that the attribute is not namespaced by banning
+                       #   colons.
+                       if ( !preg_match( '/^data-(?!ooui|mw|parsoid)[^:]*$/i', $attribute )
                                && !isset( $whitelist[$attribute] )
                        ) {
                                continue;
index a0e0b3a..0ed8270 100644 (file)
@@ -20544,7 +20544,7 @@ HTML5 data attributes
 !! test
 Strip reserved data attributes
 !! wikitext
-<div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy">d</div>
+<div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
 !! html
 <div data-ok="fred">d</div>