r70524 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70523‎ | r70524 | r70525 >
Date:20:16, 5 August 2010
Author:simetrical
Status:ok
Tags:
Comment:
Improve $wgExperimentalHtmlIds support

Now works (again?) in IE6. That didn't like getting non-legacy ID's on
redirects -- it doesn't interpret them as UTF-8, so anything non-ASCII
breaks. If this works in all the browsers I test in, I'll enable it --
it will produce *much* nicer-looking anchors for non-English wikis, and
also section names with English punctuation.
Modified paths:
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -5081,6 +5081,21 @@
50825082 }
50835083
50845084 /**
 5085+ * Same as guessSectionNameFromWikiText(), but produces legacy anchors
 5086+ * instead. For use in redirects, since IE6 interprets Redirect: headers
 5087+ * as something other than UTF-8 (apparently?), resulting in breakage.
 5088+ *
 5089+ * @param $text String: The section name
 5090+ * @return string An anchor
 5091+ */
 5092+ public function guessLegacySectionNameFromWikiText( $text ) {
 5093+ # Strip out wikitext links(they break the anchor)
 5094+ $text = $this->stripSectionName( $text );
 5095+ $text = Sanitizer::normalizeSectionNameWhitespace( $text );
 5096+ return '#' . Sanitizer::escapeId( $text, array( 'noninitial', 'legacy' ) );
 5097+ }
 5098+
 5099+ /**
50855100 * Strips a text string of wikitext for use in a section anchor
50865101 *
50875102 * Accepts a text string and then removes all wikitext from the
Index: trunk/phase3/includes/EditPage.php
@@ -1025,7 +1025,7 @@
10261026 return self::AS_TEXTBOX_EMPTY;
10271027 }
10281028 if ( $this->summary != '' ) {
1029 - $sectionanchor = $wgParser->guessSectionNameFromWikiText( $this->summary );
 1029+ $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->summary );
10301030 # This is a new section, so create a link to the new section
10311031 # in the revision summary.
10321032 $cleanSummary = $wgParser->stripSectionName( $this->summary );
@@ -1039,7 +1039,7 @@
10401040 # we can't deal with anchors, includes, html etc in the header for now,
10411041 # headline would need to be parsed to improve this
10421042 if ( $hasmatch and strlen( $matches[2] ) > 0 ) {
1043 - $sectionanchor = $wgParser->guessSectionNameFromWikiText( $matches[2] );
 1043+ $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $matches[2] );
10441044 }
10451045 }
10461046 wfProfileOut( __METHOD__ . '-sectionanchor' );

Status & tagging log