r79528 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79527‎ | r79528 | r79529 >
Date:21:04, 3 January 2011
Author:dantman
Status:resolved (Comments)
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOutput.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -3960,14 +3960,14 @@
39613961 if ( $isTemplate ) {
39623962 # Put a T flag in the section identifier, to indicate to extractSections()
39633963 # that sections inside <includeonly> should be counted.
3964 - $editlinkArgs = array( $titleText, "T-$sectionIndex", null );
 3964+ $editlinkArgs = array( $titleText, "T-$sectionIndex"/*, null */ );
39653965 } else {
39663966 $editlinkArgs = array( $this->mTitle->getPrefixedText(), $sectionIndex, $headlineHint );
39673967 }
39683968 // We use nearly the same structure as uniqPrefix and the marker stuffix (besides there being nothing random)
39693969 // However the this is output into the parser output itself not replaced early, so we hardcode this in case
39703970 // the constants change in a different version of MediaWiki, which would break this code.
3971 - $editlink = "{$this->mUniqPrefix}-editsection-" . serialize($editlinkArgs) . self::MARKER_SUFFIX;
 3971+ $editlink = "{$this->mUniqPrefix}-editsection-" . implode('|', array_map('urlencode', $editlinkArgs)) . self::MARKER_SUFFIX;
39723972 } else {
39733973 // Output edit section links directly as markup like we used to
39743974 if ( $isTemplate ) {
Index: trunk/phase3/includes/parser/ParserOutput.php
@@ -149,8 +149,11 @@
150150 */
151151 function replaceEditSectionLinksCallback( $m ) {
152152 global $wgUser, $wgLang;
153 - $args = unserialize($m[1]);
 153+ $args = array_map('urldecode', explode('|', $m[1], 3));
154154 $args[0] = Title::newFromText( $args[0] );
 155+ if ( !is_object($args[0]) ) {
 156+ throw new MWException("Bad parser output text.");
 157+ }
155158 $args[] = $wgLang->getCode();
156159 $skin = $wgUser->getSkin();
157160 return call_user_func_array( array( $skin, 'doEditSectionLink' ), $args );

Follow-up revisions

RevisionCommit summaryAuthorDate
r79558Followup r79520 and r79528, one of the args was missing when calling doEditSe...dantman04:20, 4 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79520Try to output editsection markers instead of rendered editsection links and d...dantman20:17, 3 January 2011

Comments

#Comment by OverlordQ (talk | contribs)   01:10, 4 January 2011

This is still completely FUBAR'ing parser output.

Running test -{}- tags within headlines (within html for parserConvert())... FAILED!
--- /tmp/mwParser-1753673941-expected   2011-01-04 01:09:47.000000000 +0000
+++ /tmp/mwParser-1753673941-actual     2011-01-04 01:09:47.000000000 +0000
@@ -1,2 +1,2 @@
-<h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=1" title="Уреди део: Naslov">уреди</a>]</span> <span class="mw-headline" id="-.7BNaslov.7D-"> Naslov </span></h2>
+<h2УНИQ4ц77ццд7б59е15ф-едитсецтион-Парсер+тест|1|-%7БНаслов%7Д--QИН <span class="mw-headline" id="-.7BNaslov.7D-"> Naslov </span></h2>

Status & tagging log