Revert "Strip soft hyphens (U+00AD) from title"
authorJforrester <jforrester@wikimedia.org>
Thu, 31 May 2018 17:33:31 +0000 (17:33 +0000)
committerJames D. Forrester <jforrester@wikimedia.org>
Thu, 31 May 2018 17:45:11 +0000 (10:45 -0700)
This reverts commit 6b8a5a137d3f449b4056e3de82fa6747b45f1f9a.

Change-Id: Ica5abe69c316792aa2f7eafad9b1d63183b282a8

RELEASE-NOTES-1.32
includes/title/MediaWikiTitleCodec.php
resources/src/mediawiki.Title/Title.js
tests/parser/parserTests.txt
tests/phpunit/includes/title/MediaWikiTitleCodecTest.php
tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js

index 59a5310..dca8311 100644 (file)
@@ -161,8 +161,6 @@ because of Phabricator reports.
 * The ApiQueryContributions class has been renamed to ApiQueryUserContribs.
 
 === Other changes in 1.32 ===
-* Soft hyphens (U+00AD) are now automatically removed from titles; these
-  characters can accidentally end up in copy-and-pasted titles.
 * …
 
 == Compatibility ==
index 655884b..890a870 100644 (file)
@@ -275,11 +275,10 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
                        'user_case_dbkey' => $dbkey,
                ];
 
-               # Strip soft hyphens (U+00AD) and Unicode bidi override characters
-               # (U+200E, U+200F, U+202A. U+202B, U+202C, U+202D, U+202E).
+               # Strip Unicode bidi override characters.
                # Sometimes they slip into cut-n-pasted page titles, where the
-               # soft hyphens or override chars get included in list displays.
-               $dbkey = preg_replace( '/\xC2\xAD|\xE2\x80[\x8E\x8F\xAA-\xAE]/S', '', $dbkey );
+               # override chars get included in list displays.
+               $dbkey = preg_replace( '/\xE2\x80[\x8E\x8F\xAA-\xAE]/S', '', $dbkey );
 
                # Clean up whitespace
                # Note: use of the /u option on preg_replace here will cause
index b3542cd..2b76187 100644 (file)
                rWhitespace = /[ _\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]+/g,
 
                // From MediaWikiTitleCodec::splitTitleString() in PHP
-               rStripCharacters = /[\u00AD\u200E\u200F\u202A-\u202E]/g,
+               rUnicodeBidi = /[\u200E\u200F\u202A-\u202E]/g,
 
                /**
                 * Slightly modified from Flinfo. Credit goes to Lupo and Flominator.
                        namespace = defaultNamespace === undefined ? NS_MAIN : defaultNamespace;
 
                        title = title
-                               // Strip soft hyphens and Unicode bidi override characters
-                               .replace( rStripCharacters, '' )
+                               // Strip Unicode bidi override characters
+                               .replace( rUnicodeBidi, '' )
                                // Normalise whitespace to underscores and remove duplicates
                                .replace( rWhitespace, '_' )
                                // Trim underscores
index bc0c43d..b109e39 100644 (file)
@@ -30875,27 +30875,3 @@ header
 *foo
 footer
 !! end
-
-!! test
-Check soft hyphens as entities (&shy;) in displaytitle (T66528)
-!! options
-showtitle
-title=[[Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon]]
-!! wikitext
-{{DISPLAYTITLE:Lopado&shy;temacho&shy;selacho&shy;galeo&shy;kranio&shy;leipsano&shy;drim&shy;hypo&shy;trimmato&shy;silphio&shy;parao&shy;melito&shy;katakechy&shy;meno&shy;kichl&shy;epi&shy;kossypho&shy;phatto&shy;perister&shy;alektryon&shy;opte&shy;kephallio&shy;kigklo&shy;peleio&shy;lagoio&shy;siraio&shy;baphe&shy;tragano&shy;pterygon}}
-!! html/php
-Lopado&#173;temacho&#173;selacho&#173;galeo&#173;kranio&#173;leipsano&#173;drim&#173;hypo&#173;trimmato&#173;silphio&#173;parao&#173;melito&#173;katakechy&#173;meno&#173;kichl&#173;epi&#173;kossypho&#173;phatto&#173;perister&#173;alektryon&#173;opte&#173;kephallio&#173;kigklo&#173;peleio&#173;lagoio&#173;siraio&#173;baphe&#173;tragano&#173;pterygon
-
-!! end
-
-!! test
-Check soft hyphens as Unicode characters (U+00AD) in displaytitle (T66528)
-!! options
-showtitle
-title=[[Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon]]
-!! wikitext
-{{DISPLAYTITLE:Lopado­temacho­selacho­galeo­kranio­leipsano­drim­hypo­trimmato­silphio­parao­melito­katakechy­meno­kichl­epi­kossypho­phatto­perister­alektryon­opte­kephallio­kigklo­peleio­lagoio­siraio­baphe­tragano­pterygon}}
-!! html/php
-Lopado­temacho­selacho­galeo­kranio­leipsano­drim­hypo­trimmato­silphio­parao­melito­katakechy­meno­kichl­epi­kossypho­phatto­perister­alektryon­opte­kephallio­kigklo­peleio­lagoio­siraio­baphe­tragano­pterygon
-
-!! end
index 70aa071..e1b98ec 100644 (file)
@@ -104,11 +104,6 @@ class MediaWikiTitleCodecTest extends MediaWikiTestCase {
                        // names ending in "a" to be female.
                        [ NS_USER, 'Lisa_Müller', '', '', 'de', 'Benutzerin:Lisa Müller' ],
                        [ NS_MAIN, 'FooBar', '', 'remotetestiw', 'en', 'remotetestiw:FooBar' ],
-                       // Strip soft hyphen and Unicode bidi override characters
-                       [ NS_MAIN, "Foo\xC2\xAD\xE2\x80\x8E\xE2\x80\x8F\xE2\x80\xAA\xE2\x80\xAB" .
-                               "\xE2\x80\xAC\xE2\x80\xAD\xE2\x80\xAEbar", '', '', 'en',
-                               "Foo\xC2\xAD\xE2\x80\x8E\xE2\x80\x8F\xE2\x80\xAA\xE2\x80\xAB" .
-                               "\xE2\x80\xAC\xE2\x80\xAD\xE2\x80\xAEbar", 'Foobar' ],
                ];
        }
 
index a775029..d6fe744 100644 (file)
                title = new mw.Title( 'Foo \u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000 bar' );
                assert.equal( title.getMain(), 'Foo_bar', 'Merge multiple types of whitespace/underscores into a single underscore' );
 
-               title = new mw.Title( 'Foo\u00AD\u200E\u200F\u202A\u202B\u202C\u202D\u202Ebar' );
-               assert.equal( title.getMain(), 'Foobar', 'Strip soft hyphen and Unicode bidi override characters' );
+               title = new mw.Title( 'Foo\u200E\u200F\u202A\u202B\u202C\u202D\u202Ebar' );
+               assert.equal( title.getMain(), 'Foobar', 'Strip Unicode bidi override characters' );
 
                // Regression test: Previously it would only detect an extension if there is no space after it
                title = new mw.Title( 'Example.js  ' );