Remove $wgExperimentalHtmlIds and related code, deprecated in 1.30
authorJames D. Forrester <jforrester@wikimedia.org>
Wed, 18 Apr 2018 01:22:13 +0000 (18:22 -0700)
committerJames D. Forrester <jforrester@wikimedia.org>
Tue, 1 May 2018 21:34:02 +0000 (14:34 -0700)
Bug: T139744
Change-Id: Ia15d5ab6e7637fd40d5c3399822a3dbeb7b383b5

RELEASE-NOTES-1.32
includes/DefaultSettings.php
includes/Setup.php
includes/parser/Sanitizer.php
resources/src/mediawiki/mediawiki.util.js
tests/parser/ParserTestRunner.php
tests/phpunit/includes/parser/SanitizerTest.php
tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js

index 6b3b129..3df5e0b 100644 (file)
@@ -11,6 +11,8 @@ production.
 * The $wgSiteSupportPage setting, unused since 1.5, was removed.
 * $wgJpegQuality was added to allow configuring the quality of JPEG thumbnails (default 80).
 * The default quality of JPEG thumbnails generated by GD was reduced from 95 to 80.
+* $wgExperimentalHtmlIds, deprecated since 1.30, has been removed. The 'html5-legacy' value for
+  $wgFragmentMode is no longer accepted.
 * …
 
 === New features in 1.32 ===
index 4f4fa86..6ea3b9d 100644 (file)
@@ -3372,23 +3372,12 @@ $wgApiFrameOptions = 'DENY';
  */
 $wgDisableOutputCompression = false;
 
-/**
- * Abandoned experiment with HTML5-style ID escaping. Normalized IDs a bit
- * too aggressively, breaking preexisting content (particularly Cite).
- * See T29733, T29694, T29474.
- *
- * @deprecated since 1.30, use $wgFragmentMode
- */
-$wgExperimentalHtmlIds = false;
-
 /**
  * How should section IDs be encoded?
  * This array can contain 1 or 2 elements, each of them can be one of:
  * - 'html5'  is modern HTML5 style encoding with minimal escaping. Displays Unicode
  *            characters in most browsers' address bars.
  * - 'legacy' is old MediaWiki-style encoding, e.g. 啤酒 turns into .E5.95.A4.E9.85.92
- * - 'html5-legacy' corresponds to DEPRECATED $wgExperimentalHtmlIds mode. DO NOT use
- *            it for anything but migration off that mode (see below).
  *
  * The first element of this array specifies the primary mode of escaping IDs. This
  * is what users will see when they e.g. follow an [[#internal link]] to a section of
index 6825c7b..5cc9a96 100644 (file)
@@ -361,12 +361,6 @@ foreach ( $wgForeignFileRepos as &$repo ) {
 }
 unset( $repo ); // no global pollution; destroy reference
 
-// Convert this deprecated setting to modern system
-if ( $wgExperimentalHtmlIds ) {
-       wfDeprecated( '$wgExperimentalHtmlIds', '1.30' );
-       $wgFragmentMode = [ 'html5-legacy', 'html5' ];
-}
-
 $rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 );
 if ( $wgRCFilterByAge ) {
        // Trim down $wgRCLinkDays so that it only lists links which are valid
index b13e597..118442d 100644 (file)
@@ -1180,13 +1180,12 @@ class Sanitizer {
 
        /**
         * Given a value, escape it so that it can be used in an id attribute and
-        * return it.  This will use HTML5 validation if $wgExperimentalHtmlIds is
-        * true, allowing anything but ASCII whitespace.  Otherwise it will use
-        * HTML 4 rules, which means a narrow subset of ASCII, with bad characters
-        * escaped with lots of dots.
+        * return it.  This will use HTML5 validation, allowing anything but ASCII
+        * whitespace.
+        *
+        * To ensure we don't have to bother escaping anything, we also strip ', ".
+        * TODO: Is this the best tactic?
         *
-        * To ensure we don't have to bother escaping anything, we also strip ', ",
-        * & even if $wgExperimentalIds is true.  TODO: Is this the best tactic?
         * We also strip # because it upsets IE, and % because it could be
         * ambiguous if it's part of something that looks like a percent escape
         * (which don't work reliably in fragments cross-browser).
@@ -1204,28 +1203,12 @@ class Sanitizer {
         * @param string|array $options String or array of strings (default is array()):
         *   'noninitial': This is a non-initial fragment of an id, not a full id,
         *       so don't pay attention if the first character isn't valid at the
-        *       beginning of an id.  Only matters if $wgExperimentalHtmlIds is
-        *       false.
-        *   'legacy': Behave the way the old HTML 4-based ID escaping worked even
-        *       if $wgExperimentalHtmlIds is used, so we can generate extra
-        *       anchors and links won't break.
+        *       beginning of an id.
         * @return string
         */
        static function escapeId( $id, $options = [] ) {
-               global $wgExperimentalHtmlIds;
                $options = (array)$options;
 
-               if ( $wgExperimentalHtmlIds && !in_array( 'legacy', $options ) ) {
-                       $id = preg_replace( '/[ \t\n\r\f_\'"&#%]+/', '_', $id );
-                       $id = trim( $id, '_' );
-                       if ( $id === '' ) {
-                               // Must have been all whitespace to start with.
-                               return '_';
-                       } else {
-                               return $id;
-                       }
-               }
-
                // HTML4-style escaping
                static $replace = [
                        '%3A' => ':',
@@ -1337,14 +1320,6 @@ class Sanitizer {
                                $id = urlencode( str_replace( ' ', '_', $id ) );
                                $id = strtr( $id, $replace );
                                break;
-                       case 'html5-legacy':
-                               $id = preg_replace( '/[ \t\n\r\f_\'"&#%]+/', '_', $id );
-                               $id = trim( $id, '_' );
-                               if ( $id === '' ) {
-                                       // Must have been all whitespace to start with.
-                                       $id = '_';
-                               }
-                               break;
                        default:
                                throw new InvalidArgumentException( "Invalid mode '$mode' passed to '" . __METHOD__ );
                }
index 9f6167a..f0c74ce 100644 (file)
                switch ( mode ) {
                        case 'html5':
                                return str.replace( / /g, '_' );
-                       case 'html5-legacy':
-                               str = str.replace( /[ \t\n\r\f_'"&#%]+/g, '_' )
-                                       .replace( /^_+|_+$/, '' );
-                               if ( str === '' ) {
-                                       str = '_';
-                               }
-                               return str;
                        case 'legacy':
                                return rawurlencode( str.replace( / /g, '_' ) )
                                        .replace( /%3A/g, ':' )
index 91ddf24..77ef43e 100644 (file)
@@ -271,7 +271,6 @@ class ParserTestRunner {
                $setup['wgNoFollowLinks'] = true;
                $setup['wgNoFollowDomainExceptions'] = [ 'no-nofollow.org' ];
                $setup['wgExternalLinkTarget'] = false;
-               $setup['wgExperimentalHtmlIds'] = false;
                $setup['wgLocaltimezone'] = 'UTC';
                $setup['wgHtml5'] = true;
                $setup['wgDisableLangConversion'] = false;
index 6590338..b5965c4 100644 (file)
@@ -457,7 +457,6 @@ class SanitizerTest extends MediaWikiTestCase {
                $legacyEncoded = 'foo_.D1.82.D0.B5.D1.81.D1.82_.23.25.21.27.28.29.5B.5D:.3C.3E' .
                        '.26.26amp.3B.26amp.3Bamp.3B';
                $html5Encoded = 'foo_тест_#%!\'()[]:<>&&amp;&amp;amp;';
-               $html5Experimental = 'foo_тест_!_()[]:<>_amp;_amp;amp;';
 
                // Settings: last element is $wgExternalInterwikiFragmentMode, the rest is $wgFragmentMode
                $legacy = [ 'legacy', 'legacy' ];
@@ -465,8 +464,6 @@ class SanitizerTest extends MediaWikiTestCase {
                $newLegacy = [ 'html5', 'legacy', 'legacy' ];
                $new = [ 'html5', 'legacy' ];
                $allNew = [ 'html5', 'html5' ];
-               $experimentalLegacy = [ 'html5-legacy', 'legacy', 'legacy' ];
-               $newExperimental = [ 'html5', 'html5-legacy', 'legacy' ];
 
                return [
                        // Pure legacy: how MW worked before 2017
@@ -498,18 +495,6 @@ class SanitizerTest extends MediaWikiTestCase {
                        [ 'Attribute', $allNew, $text, false, Sanitizer::ID_FALLBACK ],
                        [ 'Link', $allNew, $text, $html5Encoded ],
                        [ 'ExternalInterwiki', $allNew, $text, $html5Encoded ],
-
-                       // Someone flipped $wgExperimentalHtmlIds on
-                       [ 'Attribute', $experimentalLegacy, $text, $html5Experimental, Sanitizer::ID_PRIMARY ],
-                       [ 'Attribute', $experimentalLegacy, $text, $legacyEncoded, Sanitizer::ID_FALLBACK ],
-                       [ 'Link', $experimentalLegacy, $text, $html5Experimental ],
-                       [ 'ExternalInterwiki', $experimentalLegacy, $text, $legacyEncoded ],
-
-                       // Migration from $wgExperimentalHtmlIds to modern HTML5
-                       [ 'Attribute', $newExperimental, $text, $html5Encoded, Sanitizer::ID_PRIMARY ],
-                       [ 'Attribute', $newExperimental, $text, $html5Experimental, Sanitizer::ID_FALLBACK ],
-                       [ 'Link', $newExperimental, $text, $html5Encoded ],
-                       [ 'ExternalInterwiki', $newExperimental, $text, $legacyEncoded ],
                ];
        }
 
index b8464e9..5508088 100644 (file)
                var text = 'foo тест_#%!\'()[]:<>',
                        legacyEncoded = 'foo_.D1.82.D0.B5.D1.81.D1.82_.23.25.21.27.28.29.5B.5D:.3C.3E',
                        html5Encoded = 'foo_тест_#%!\'()[]:<>',
-                       html5Experimental = 'foo_тест_!_()[]:<>',
                        // Settings: this is $wgFragmentMode
                        legacy = [ 'legacy' ],
                        legacyNew = [ 'legacy', 'html5' ],
                        newLegacy = [ 'html5', 'legacy' ],
-                       allNew = [ 'html5' ],
-                       experimentalLegacy = [ 'html5-legacy', 'legacy' ],
-                       newExperimental = [ 'html5', 'html5-legacy' ];
+                       allNew = [ 'html5' ];
 
                // Test cases are kept in sync with SanitizerTest.php
                [
                        // New world: HTML5 links, legacy fallbacks
                        [ newLegacy, text, html5Encoded ],
                        // Distant future: no legacy fallbacks
-                       [ allNew, text, html5Encoded ],
-                       // Someone flipped $wgExperimentalHtmlIds on
-                       [ experimentalLegacy, text, html5Experimental ],
-                       // Migration from $wgExperimentalHtmlIds to modern HTML5
-                       [ newExperimental, text, html5Encoded ]
+                       [ allNew, text, html5Encoded ]
                ].forEach( function ( testCase ) {
                        mw.config.set( 'wgFragmentMode', testCase[ 0 ] );
 
                var text = 'foo тест_#%!\'()[]:<>',
                        legacyEncoded = 'foo_.D1.82.D0.B5.D1.81.D1.82_.23.25.21.27.28.29.5B.5D:.3C.3E',
                        html5Encoded = 'foo_тест_#%!\'()[]:<>',
-                       html5Experimental = 'foo_тест_!_()[]:<>',
                        // Settings: this is wgFragmentMode
                        legacy = [ 'legacy' ],
                        legacyNew = [ 'legacy', 'html5' ],
                        newLegacy = [ 'html5', 'legacy' ],
-                       allNew = [ 'html5' ],
-                       experimentalLegacy = [ 'html5-legacy', 'legacy' ],
-                       newExperimental = [ 'html5', 'html5-legacy' ];
+                       allNew = [ 'html5' ];
 
                [
                        // Pure legacy: how MW worked before 2017
                        // New world: HTML5 links, legacy fallbacks
                        [ newLegacy, text, html5Encoded ],
                        // Distant future: no legacy fallbacks
-                       [ allNew, text, html5Encoded ],
-                       // Someone flipped wgExperimentalHtmlIds on
-                       [ experimentalLegacy, text, html5Experimental ],
-                       // Migration from wgExperimentalHtmlIds to modern HTML5
-                       [ newExperimental, text, html5Encoded ]
+                       [ allNew, text, html5Encoded ]
                ].forEach( function ( testCase ) {
                        mw.config.set( 'wgFragmentMode', testCase[ 0 ] );