McIntireEvan has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/181942

Change subject: Moved getTitleInvalidRegex()
......................................................................

Moved getTitleInvalidRegex()

Moved getTitleInvalidRegex() from Title to MediaWikiTitleCodec, updated
all references in core to use the new one, and deprecated the current one
in Title

Change-Id: I2b9c36992028c97f695f2b95ba027fbb11904b57
---
M includes/Title.php
M includes/title/MediaWikiTitleCodec.php
M languages/Language.php
M resources/src/mediawiki/mediawiki.Title.js
4 files changed, 32 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/42/181942/1

diff --git a/includes/Title.php b/includes/Title.php
index cf11bd3..facdcdb 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -610,15 +610,16 @@
        }
 
        /**
+        * @deprecated since 1.24.1, use 
MediaWikiTitleCodec::getTitleInvalidRegex() instead
+        *
         * Returns a simple regex that will match on characters and sequences 
invalid in titles.
         * Note that this doesn't pick up many things that could be wrong with 
titles, but that
         * replacing this regex with something valid will make many titles 
valid.
         *
-        * @todo move this into MediaWikiTitleCodec
-        *
         * @return string Regex string
         */
        static function getTitleInvalidRegex() {
+               wfDeprecated(__METHOD__, '1.24.1'); 
                static $rxTc = false;
                if ( !$rxTc ) {
                        # Matching titles will be held as illegal.
diff --git a/includes/title/MediaWikiTitleCodec.php 
b/includes/title/MediaWikiTitleCodec.php
index 0185b97..02d0d03 100644
--- a/includes/title/MediaWikiTitleCodec.php
+++ b/includes/title/MediaWikiTitleCodec.php
@@ -398,4 +398,31 @@
 
                return $parts;
        }
+
+       /**
+        * Returns a simple regex that will match on characters and sequences 
invalid in titles.
+        * Note that this doesn't pick up many things that could be wrong with 
titles, but that
+        * replacing this regex with something valid will make many titles 
valid.
+        *
+        * @return string Regex string
+        */
+       static function getTitleInvalidRegex() {
+               static $rxTc = false;
+               if ( !$rxTc ) {
+                       # Matching titles will be held as illegal.
+                       $rxTc = '/' .
+                               # Any character not allowed is forbidden...
+                               '[^' . Title::legalChars() . ']' .
+                               # URL percent encoding sequences interfere with 
the ability
+                               # to round-trip titles -- you can't link to 
them consistently.
+                               '|%[0-9A-Fa-f]{2}' .
+                               # XML/HTML character references produce similar 
issues.
+                               '|&[A-Za-z0-9\x80-\xff]+;' .
+                               '|&#[0-9]+;' .
+                               '|&#x[0-9A-Fa-f]+;' .
+                               '/S';
+               }
+
+               return $rxTc;   
+       }
 }
diff --git a/languages/Language.php b/languages/Language.php
index 01fb986..5ee9953 100644
--- a/languages/Language.php
+++ b/languages/Language.php
@@ -318,7 +318,7 @@
                // see bugs 37564, 37587, 36938
                $cache[$code] =
                        strcspn( $code, ":/\\\000&<>'\"" ) === strlen( $code )
-                       && !preg_match( Title::getTitleInvalidRegex(), $code );
+                       && !preg_match( 
MediaWikiTitleCodec::getTitleInvalidRegex(), $code );
 
                return $cache[$code];
        }
diff --git a/resources/src/mediawiki/mediawiki.Title.js 
b/resources/src/mediawiki/mediawiki.Title.js
index 5e594ad..eaf079f 100644
--- a/resources/src/mediawiki/mediawiki.Title.js
+++ b/resources/src/mediawiki/mediawiki.Title.js
@@ -119,7 +119,7 @@
 
        rSplit = /^(.+?)_*:_*(.*)$/,
 
-       // See Title.php#getTitleInvalidRegex
+       // See MediaWikiTitleCodec.php#getTitleInvalidRegex
        rInvalid = new RegExp(
                '[^' + mw.config.get( 'wgLegalTitleChars' ) + ']' +
                // URL percent encoding sequences interfere with the ability

-- 
To view, visit https://gerrit.wikimedia.org/r/181942
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b9c36992028c97f695f2b95ba027fbb11904b57
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: McIntireEvan <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to