From: Aryeh Gregor Date: Mon, 15 Apr 2019 12:42:03 +0000 (+0300) Subject: Normalize input to TitleParser::parseTitle() X-Git-Tag: 1.34.0-rc.0~1940^2~2 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=29bfd8b39b01bdd3232d5be16c71e6f2ead31fc3;p=lhc%2Fweb%2Fwiklou.git Normalize input to TitleParser::parseTitle() This matches behavior of Title::newFromText(), which assists porting old code to TitleParser. Change-Id: I50e9af09df843ea575250e276c7cfce660c00efd --- diff --git a/includes/title/MediaWikiTitleCodec.php b/includes/title/MediaWikiTitleCodec.php index adbea89db7..b2c8521449 100644 --- a/includes/title/MediaWikiTitleCodec.php +++ b/includes/title/MediaWikiTitleCodec.php @@ -149,10 +149,13 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser { * @return TitleValue */ public function parseTitle( $text, $defaultNamespace = NS_MAIN ) { + // Convert things like é ā or 〗 into normalized (T16952) text + $filteredText = Sanitizer::decodeCharReferencesAndNormalize( $text ); + // NOTE: this is an ugly cludge that allows this class to share the // code for parsing with the old Title class. The parser code should // be refactored to avoid this. - $parts = $this->splitTitleString( $text, $defaultNamespace ); + $parts = $this->splitTitleString( $filteredText, $defaultNamespace ); // Relative fragment links are not supported by TitleValue if ( $parts['dbkey'] === '' ) { diff --git a/tests/phpunit/includes/title/MediaWikiTitleCodecTest.php b/tests/phpunit/includes/title/MediaWikiTitleCodecTest.php index 20f0039f57..5e8bf6637f 100644 --- a/tests/phpunit/includes/title/MediaWikiTitleCodecTest.php +++ b/tests/phpunit/includes/title/MediaWikiTitleCodecTest.php @@ -298,7 +298,9 @@ class MediaWikiTitleCodecTest extends MediaWikiTestCase { new TitleValue( NS_CATEGORY, 'X' . str_repeat( 'x', 247 ) ) ], [ str_repeat( 'x', 252 ), NS_MAIN, 'en', - 'X' . str_repeat( 'x', 251 ) ] + 'X' . str_repeat( 'x', 251 ) ], + // Test decoding and normalization + [ '"ñ"', NS_MAIN, 'en', new TitleValue( NS_MAIN, '"ñ"' ) ], ]; }