Fix enhanced RC data attribute sanitizing
authorGergő Tisza <tgr.huwiki@gmail.com>
Wed, 14 Jun 2017 21:01:31 +0000 (23:01 +0200)
committerGreg Grossmeier <greg@wikimedia.org>
Thu, 15 Jun 2017 00:02:44 +0000 (00:02 +0000)
We push 'class' in the attribute array so the hook
can manipulate it, so it needs to be added to the attribute
whitelist as well.

Broken in I6dd006d0b1b0fd35c0020f0f9eea9113eca30b35.

Bug: T167922
Bug: T167535
Change-Id: Ic24400382a9dcbb990e12dfddae4ab7db14553cc

includes/changes/EnhancedChangesList.php
tests/phpunit/includes/changes/EnhancedChangesListTest.php

index 03f63f6..d977457 100644 (file)
@@ -686,7 +686,9 @@ class EnhancedChangesList extends ChangesList {
                }
                $attribs = $data['attribs'];
                unset( $data['attribs'] );
-               $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] );
+               $attribs = wfArrayFilterByKey( $attribs, function( $key ) {
+                       return $key === 'class' || Sanitizer::isReservedDataAttribute( $key );
+               } );
 
                $line = Html::openElement( 'table', $attribs ) . Html::openElement( 'tr' );
                $line .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
index 029d1fe..28818d9 100644 (file)
@@ -99,7 +99,7 @@ class EnhancedChangesListTest extends MediaWikiLangTestCase {
                $enhancedChangesList->recentChangesLine( $recentChange, false );
 
                $html = $enhancedChangesList->endRecentChangesList();
-               $this->assertContains( 'data-mw-revid="5"', $html );
+               $this->assertRegExp( '/data-mw-revid="5" class="[^"]*mw-enhanced-rc[^"]*"/', $html );
 
                $recentChange2 = $this->getEditChange( '20131103092253' );
                $enhancedChangesList->recentChangesLine( $recentChange2, false );