r45470 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45469‎ | r45470 | r45471 >
Date:00:00, 7 January 2009
Author:brion
Status:ok
Tags:
Comment:
Reverting r45341 " Use Sanitizer::escapeId() in another place Reduce code duplication some more, and fix section redirect after edit
when $wgEnforceHtmlIds is off."

This produces non-matching stuff like "#_Rock_on_dudes_" for == ''Rock on'' dudes ==.
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -4736,11 +4736,21 @@
47374737 * "== Header ==".
47384738 */
47394739 public function guessSectionNameFromWikiText( $text ) {
4740 - global $wgEnforceHtmlIds;
47414740 # Strip out wikitext links(they break the anchor)
47424741 $text = $this->stripSectionName( $text );
4743 - return '#' . Sanitizer::escapeId( $text,
4744 - $wgEnforceHtmlIds ? 'noninitial' : 'xml' );
 4742+ $headline = Sanitizer::decodeCharReferences( $text );
 4743+ # strip out HTML
 4744+ $headline = StringUtils::delimiterReplace( '<', '>', '', $headline );
 4745+ $headline = trim( $headline );
 4746+ $sectionanchor = '#' . urlencode( str_replace( ' ', '_', $headline ) );
 4747+ $replacearray = array(
 4748+ '%3A' => ':',
 4749+ '%' => '.'
 4750+ );
 4751+ return str_replace(
 4752+ array_keys( $replacearray ),
 4753+ array_values( $replacearray ),
 4754+ $sectionanchor );
47454755 }
47464756
47474757 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r45473Reduce code duplication correctly this time...simetrical00:41, 7 January 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r45341Use Sanitizer::escapeId() in another place...simetrical20:30, 2 January 2009

Status & tagging log