From 1888bf5601af86eb68d7840da3d12c08839dc01f Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Tue, 22 Dec 2015 18:24:33 -0500 Subject: [PATCH] Don't allow atttributes whose namespace starts with `data-`. Change-Id: Ia76c74941b09e3ad131fe2fee31ffec3e540170b --- includes/Sanitizer.php | 4 +++- tests/parser/parserTests.txt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index 4fc775ff4c..5242856434 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -756,7 +756,9 @@ class Sanitizer { # * data-mw- 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; diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index a0e0b3a220..0ed8270e50 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -20544,7 +20544,7 @@ HTML5 data attributes !! test Strip reserved data attributes !! wikitext -
d
+
d
!! html
d
-- 2.20.1