From ecd545b1fd34eb2e9a33a258265c88814b853b68 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Mon, 3 Jan 2011 21:04:05 +0000 Subject: [PATCH] Followup r79520, some characters inside the encoded data were being modified by the parser causing it to break. Switching to a encoding scheme without that issue and adding a test to throw a less fatal error. --- includes/parser/Parser.php | 4 ++-- includes/parser/ParserOutput.php | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index b723bea433..37f5149c8a 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3960,14 +3960,14 @@ class Parser { if ( $isTemplate ) { # Put a T flag in the section identifier, to indicate to extractSections() # that sections inside 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 ) { diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 59552ad108..32153e653a 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -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 ); -- 2.20.1