Merge "Reserve data-mw and data-parsoid attribute prefix for trusted values"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 9 Dec 2015 06:54:56 +0000 (06:54 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 9 Dec 2015 06:54:56 +0000 (06:54 +0000)
1  2 
includes/Sanitizer.php

diff --combined includes/Sanitizer.php
@@@ -750,7 -750,15 +750,15 @@@ class Sanitizer 
                        }
  
                        # Allow any attribute beginning with "data-"
-                       if ( !preg_match( '/^data-(?!ooui)/i', $attribute ) && !isset( $whitelist[$attribute] ) ) {
+                       # However:
+                       # * data-ooui is reserved for ooui
+                       # * data-mw and data-parsoid are reserved for parsoid
+                       # * data-mw-<ext 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 )
+                               && !isset( $whitelist[$attribute] )
+                       ) {
                                continue;
                        }
  
  
                        # 10.2
                        'ul'         => array_merge( $common, array( 'type' ) ),
 -                      'ol'         => array_merge( $common, array( 'type', 'start' ) ),
 +                      'ol'         => array_merge( $common, array( 'type', 'start', 'reversed' ) ),
                        'li'         => array_merge( $common, array( 'type', 'value' ) ),
  
                        # 10.3