Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -3699,7 +3699,7 @@ |
3700 | 3700 | if ( $showEditLink ) { |
3701 | 3701 | $editLinkAsToken = $this->mOptions->getEditSectionTokens(); |
3702 | 3702 | if ( $editLinkAsToken ) { |
3703 | | - $this->mOutput->setEditSectionTokens( "{$this->mUniqPrefix}-editsection-", self::MARKER_SUFFIX ); |
| 3703 | + $this->mOutput->setEditSectionTokens( true ); |
3704 | 3704 | } |
3705 | 3705 | } |
3706 | 3706 | |
— | — | @@ -3964,10 +3964,20 @@ |
3965 | 3965 | } else { |
3966 | 3966 | $editlinkArgs = array( $this->mTitle->getPrefixedText(), $sectionIndex, $headlineHint ); |
3967 | 3967 | } |
3968 | | - // We use nearly the same structure as uniqPrefix and the marker stuffix (besides there being nothing random) |
3969 | | - // However the this is output into the parser output itself not replaced early, so we hardcode this in case |
3970 | | - // the constants change in a different version of MediaWiki, which would break this code. |
3971 | | - $editlink = "{$this->mUniqPrefix}-editsection-" . implode('|', array_map('urlencode', $editlinkArgs)) . self::MARKER_SUFFIX; |
| 3968 | + // We use a bit of pesudo-xml for editsection markers. The language converter is run later on |
| 3969 | + // Using a UNIQ style marker leads to the converter screwing up the tokens when it converts stuff |
| 3970 | + // And trying to insert strip tags fails too. At this point all real inputted tags have already been escaped |
| 3971 | + // so we don't have to worry about a user trying to input one of these markers directly. |
| 3972 | + // We use a page and section attribute to stop the language converter from converting these important bits |
| 3973 | + // of data, but put the headline hint inside a content block because the language converter is supposed to |
| 3974 | + // be able to convert that piece of data. |
| 3975 | + $editlink = '<editsection page="' . htmlspecialchars($editlinkArgs[0]); |
| 3976 | + $editlink .= '" section="' . htmlspecialchars($editlinkArgs[1]) .'"'; |
| 3977 | + if ( isset($editlinkArgs[2]) ) { |
| 3978 | + $editlink .= '>' . $editlinkArgs[2] . '</editsection>'; |
| 3979 | + } else { |
| 3980 | + $editlink .= '/>'; |
| 3981 | + } |
3972 | 3982 | } else { |
3973 | 3983 | // Output edit section links directly as markup like we used to |
3974 | 3984 | if ( $isTemplate ) { |
Index: trunk/phase3/includes/parser/ParserOutput.php |
— | — | @@ -137,8 +137,7 @@ |
138 | 138 | |
139 | 139 | function getText() { |
140 | 140 | if ( $this->mEditSectionTokens ) { |
141 | | - $editSectionTokens = $this->mEditSectionTokens; |
142 | | - return preg_replace_callback( "#{$editSectionTokens[0]}(.*?){$editSectionTokens[1]}#", array( &$this, 'replaceEditSectionLinksCallback' ), $this->mText ); |
| 141 | + return preg_replace_callback( '#<editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</editsection>))#', array( &$this, 'replaceEditSectionLinksCallback' ), $this->mText ); |
143 | 142 | } |
144 | 143 | return $this->mText; |
145 | 144 | } |
— | — | @@ -149,7 +148,11 @@ |
150 | 149 | */ |
151 | 150 | function replaceEditSectionLinksCallback( $m ) { |
152 | 151 | global $wgUser, $wgLang; |
153 | | - $args = array_map('urldecode', explode('|', $m[1], 3)); |
| 152 | + $args = array( |
| 153 | + htmlspecialchars_decode($m[1]), |
| 154 | + htmlspecialchars_decode($m[2]), |
| 155 | + $m[4] ? $m[3] : null, |
| 156 | + ); |
154 | 157 | $args[0] = Title::newFromText( $args[0] ); |
155 | 158 | if ( !is_object($args[0]) ) { |
156 | 159 | throw new MWException("Bad parser output text."); |
— | — | @@ -184,7 +187,7 @@ |
185 | 188 | |
186 | 189 | function setTitleText( $t ) { return wfSetVar( $this->mTitleText, $t ); } |
187 | 190 | function setSections( $toc ) { return wfSetVar( $this->mSections, $toc ); } |
188 | | - function setEditSectionTokens( $p, $s ) { return wfSetVar( $this->mEditSectionTokens, array( $p, $s ) ); } |
| 191 | + function setEditSectionTokens( $t ) { return wfSetVar( $this->mEditSectionTokens, $t ); } |
189 | 192 | function setIndexPolicy( $policy ) { return wfSetVar( $this->mIndexPolicy, $policy ); } |
190 | 193 | function setTOCHTML( $tochtml ) { return wfSetVar( $this->mTOCHTML, $tochtml ); } |
191 | 194 | |