(bug 33321. Sort of) Adding a line to MediaWiki:Sidebar that contains a pipe, but...
authorBrian Wolff <bawolff@users.mediawiki.org>
Thu, 5 Jan 2012 15:34:26 +0000 (15:34 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Thu, 5 Jan 2012 15:34:26 +0000 (15:34 +0000)
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 &#124; not working.

RELEASE-NOTES-1.19
includes/Skin.php
tests/phpunit/skins/SideBarTest.php

index 383ba4e..edc84ed 100644 (file)
@@ -218,6 +218,9 @@ production.
   HTTPS when the local wiki is served over HTTPS.
 * (bug 33525) clearTagHooks doesn't clear function hooks.
 * (bug 33523) Function tag hooks don't appear on Special:Version.
+* (bug 33321) 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.
 
 === API changes in 1.19 ===
 * (bug 19838) siprop=interwikimap can now use the interwiki cache.
index 1841f8a..bb81782 100644 (file)
@@ -1244,6 +1244,12 @@ abstract class Skin extends ContextSource {
                                if ( strpos( $line, '|' ) !== false ) { // sanity check
                                        $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
                                        $line = array_map( 'trim', explode( '|', $line, 2 ) );
+                                       if ( count( $line ) !== 2 ) {
+                                               // Second sanity check, could be hit by people doing
+                                               // funky stuff with parserfuncs... (bug 3321)
+                                               continue;
+                                       }
+
                                        $extraAttribs = array();
 
                                        $msgLink = $this->msg( $line[0] )->inContentLanguage();
@@ -1255,7 +1261,6 @@ abstract class Skin extends ContextSource {
                                        } else {
                                                $link = $line[0];
                                        }
-
                                        $msgText = $this->msg( $line[1] );
                                        if ( $msgText->exists() ) {
                                                $text = $msgText->text();
index ed74c6e..1734fd2 100644 (file)
@@ -106,6 +106,36 @@ class SideBarTest extends MediaWikiLangTestCase {
                );
 
        }
+       /** bug 33321 */
+       function testTrickyPipe() {
+               $this->assertSidebar(
+               array( 'Title' => array(
+                       # The first 2 are skipped
+                       # Doesn't really test the url properly
+                       # because it will vary with $wgArticlePath et al.
+                       # ** Baz|Fred
+                       array(
+                               'text'   => 'Fred',
+                               'href'   => Title::newFromText( 'Baz' )->getLocalUrl(),
+                               'id'     => 'n-Fred',
+                               'active' => null,
+                       ),
+                       array(
+                               'text'   => 'title-to-display',
+                               'href'   => Title::newFromText( 'page-to-go-to' )->getLocalUrl(),
+                               'id'     => 'n-title-to-display',
+                               'active' => null,
+                       ),
+               )),
+'* Title
+** {{PAGENAME|Foo}}
+** Bar
+** Baz|Fred
+** {{PLURAL:1|page-to-go-to{{int:pipe-separator/en}}title-to-display|branch not taken}}
+'
+               );
+
+       }
 
 
        #### Attributes for external links ##########################