r108145 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108144‎ | r108145 | r108146 >
Date:15:34, 5 January 2012
Author:bawolff
Status:resolved (Comments)
Tags:
Comment:
(bug 33321. Sort of) Adding a line to MediaWiki:Sidebar that contains a pipe, but doesn't
have any pipes after being transformed by MessageCache, causes exception on
all pages.

This can happen with lines like:
**{{#if:yes|Something}}

Thank you to liangent for figuring out how to escape a | without {{!}} existing and | not working.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/tests/phpunit/skins/SideBarTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Skin.php
@@ -1244,6 +1244,12 @@
12451245 if ( strpos( $line, '|' ) !== false ) { // sanity check
12461246 $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
12471247 $line = array_map( 'trim', explode( '|', $line, 2 ) );
 1248+ if ( count( $line ) !== 2 ) {
 1249+ // Second sanity check, could be hit by people doing
 1250+ // funky stuff with parserfuncs... (bug 3321)
 1251+ continue;
 1252+ }
 1253+
12481254 $extraAttribs = array();
12491255
12501256 $msgLink = $this->msg( $line[0] )->inContentLanguage();
@@ -1255,7 +1261,6 @@
12561262 } else {
12571263 $link = $line[0];
12581264 }
1259 -
12601265 $msgText = $this->msg( $line[1] );
12611266 if ( $msgText->exists() ) {
12621267 $text = $msgText->text();
Index: trunk/phase3/tests/phpunit/skins/SideBarTest.php
@@ -106,8 +106,38 @@
107107 );
108108
109109 }
 110+ /** bug 33321 */
 111+ function testTrickyPipe() {
 112+ $this->assertSidebar(
 113+ array( 'Title' => array(
 114+ # The first 2 are skipped
 115+ # Doesn't really test the url properly
 116+ # because it will vary with $wgArticlePath et al.
 117+ # ** Baz|Fred
 118+ array(
 119+ 'text' => 'Fred',
 120+ 'href' => Title::newFromText( 'Baz' )->getLocalUrl(),
 121+ 'id' => 'n-Fred',
 122+ 'active' => null,
 123+ ),
 124+ array(
 125+ 'text' => 'title-to-display',
 126+ 'href' => Title::newFromText( 'page-to-go-to' )->getLocalUrl(),
 127+ 'id' => 'n-title-to-display',
 128+ 'active' => null,
 129+ ),
 130+ )),
 131+'* Title
 132+** {{PAGENAME|Foo}}
 133+** Bar
 134+** Baz|Fred
 135+** {{PLURAL:1|page-to-go-to{{int:pipe-separator/en}}title-to-display|branch not taken}}
 136+'
 137+ );
110138
 139+ }
111140
 141+
112142 #### Attributes for external links ##########################
113143 private function getAttribs( ) {
114144 # Sidebar text we will use everytime
Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -218,6 +218,9 @@
219219 HTTPS when the local wiki is served over HTTPS.
220220 * (bug 33525) clearTagHooks doesn't clear function hooks.
221221 * (bug 33523) Function tag hooks don't appear on Special:Version.
 222+* (bug 33321) Adding a line to MediaWiki:Sidebar that contains a pipe, but doesn't
 223+ have any pipes after being transformed by MessageCache, causes exception on
 224+ all pages.
222225
223226 === API changes in 1.19 ===
224227 * (bug 19838) siprop=interwikimap can now use the interwiki cache.

Follow-up revisions

RevisionCommit summaryAuthorDate
r108322(follow-up r108145) Mark test as needing a database, and fix bug number in co...bawolff15:43, 7 January 2012
r108625MFT r108345, r108145 without tests/release-notesreedy15:31, 11 January 2012
r108629Merge r108145, moved RELEASE-NOTES to 1.18reedy15:44, 11 January 2012
r108630Remove RELEASE-NOTES-1.19 from r108145, moved to 1.18 in r108629reedy15:45, 11 January 2012

Comments

#Comment by Bawolff (talk | contribs)   19:59, 5 January 2012

Tagging 1.18. Its very easy for a user to totally screw up their wiki in a way thats difficult to revert (aka need to use maintinance script or api to revert a bad edit to sidebar that triggers this bug).

#Comment by Platonides (talk | contribs)   13:00, 7 January 2012

The test needs a database. The change to Skin.php looks good.

#Comment by Platonides (talk | contribs)   13:01, 7 January 2012

...but the bug number in the source misses a 3.

Status & tagging log