Polish up r45109 (changes to header id generation)
authorAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 28 Dec 2008 03:31:21 +0000 (03:31 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 28 Dec 2008 03:31:21 +0000 (03:31 +0000)
1) Make sure internal links are using the new encoding scheme and still
work (this also reduces code duplication)

2) Make sure no id can start with a nonletter, not just header id's

No parser test regressions.

RELEASE-NOTES
includes/Sanitizer.php
includes/Title.php
maintenance/parserTests.txt

index 62cd3b6..8f3d130 100644 (file)
@@ -457,7 +457,7 @@ The following extensions are migrated into MediaWiki 1.14:
 * (bug 13835) Fix rendering of {{filepath:Wiki.png|nowiki}}
 * (bug 16772) Special:Upload now correctly rejects files with spaces in the
   file extension (e.g. Foo. jpg).
-* Ensure that all HTML id's generated for headers begin with a letter.
+* Ensure that all HTML id's begin with a letter as required by XHTML standard
 
 === API changes in 1.14 ===
 
index 84cc7f8..28ae4cb 100644 (file)
@@ -617,7 +617,7 @@ class Sanitizer {
                        }
 
                        if ( $attribute === 'id' )
-                               $value = Sanitizer::escapeId( $value );
+                               $value = Sanitizer::escapeId( $value, Sanitizer::NONE );
 
                        // If this attribute was previously set, override it.
                        // Output should only have one attribute of each name.
index 4f82e95..abfae90 100644 (file)
@@ -451,13 +451,7 @@ class Title {
         * Escape a text fragment, say from a link, for a URL
         */
        static function escapeFragmentForURL( $fragment ) {
-               $fragment = str_replace( ' ', '_', $fragment );
-               $fragment = urlencode( Sanitizer::decodeCharReferences( $fragment ) );
-               $replaceArray = array(
-                       '%3A' => ':',
-                       '%' => '.'
-               );
-               return strtr( $fragment, $replaceArray );
+               return Sanitizer::escapeId( $fragment, Sanitizer::NONE );
        }
 
 #----------------------------------------------------------------------------
index 8e514e4..a30db63 100644 (file)
@@ -1454,7 +1454,7 @@ Example for such a section: == < ==
 !! input
 [[%23%3c]][[%23%3e]]
 !! result
-<p><a href="#.3C" title="">#&lt;</a><a href="#.3E" title="">#&gt;</a>
+<p><a href="#x.3C" title="">#&lt;</a><a href="#x.3E" title="">#&gt;</a>
 </p>
 !! end
 
@@ -4662,7 +4662,7 @@ Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=
 !! input
 <span id="æ: v">byte</span>[[#æ: v|backlink]]
 !! result
-<p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v" title="">backlink</a>
+<p><span id="x.C3.A6:_v">byte</span><a href="#x.C3.A6:_v" title="">backlink</a>
 </p>
 !! end