Followup r79520, some characters inside the encoded data were being modified by the...
authorDaniel Friesen <dantman@users.mediawiki.org>
Mon, 3 Jan 2011 21:04:05 +0000 (21:04 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Mon, 3 Jan 2011 21:04:05 +0000 (21:04 +0000)
includes/parser/Parser.php
includes/parser/ParserOutput.php

index b723bea..37f5149 100644 (file)
@@ -3960,14 +3960,14 @@ class Parser {
                                        if ( $isTemplate ) {
                                                # Put a T flag in the section identifier, to indicate to extractSections()
                                                # that sections inside <includeonly> should be counted.
-                                               $editlinkArgs = array( $titleText, "T-$sectionIndex", null );
+                                               $editlinkArgs = array( $titleText, "T-$sectionIndex"/*, null */ );
                                        } else {
                                                $editlinkArgs = array( $this->mTitle->getPrefixedText(), $sectionIndex, $headlineHint );
                                        }
                                        // We use nearly the same structure as uniqPrefix and the marker stuffix (besides there being nothing random)
                                        // However the this is output into the parser output itself not replaced early, so we hardcode this in case
                                        // the constants change in a different version of MediaWiki, which would break this code.
-                                       $editlink = "{$this->mUniqPrefix}-editsection-" . serialize($editlinkArgs) . self::MARKER_SUFFIX;
+                                       $editlink = "{$this->mUniqPrefix}-editsection-" . implode('|', array_map('urlencode', $editlinkArgs)) . self::MARKER_SUFFIX;
                                } else {
                                        // Output edit section links directly as markup like we used to
                                        if ( $isTemplate ) {
index 59552ad..32153e6 100644 (file)
@@ -149,8 +149,11 @@ class ParserOutput extends CacheTime {
         */
        function replaceEditSectionLinksCallback( $m ) {
                global $wgUser, $wgLang;
-               $args = unserialize($m[1]);
+               $args = array_map('urldecode', explode('|', $m[1], 3));
                $args[0] = Title::newFromText( $args[0] );
+               if ( !is_object($args[0]) ) {
+                       throw new MWException("Bad parser output text.");
+               }
                $args[] = $wgLang->getCode();
                $skin = $wgUser->getSkin();
                return call_user_func_array( array( $skin, 'doEditSectionLink' ), $args );