r57098 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57097‎ | r57098 | r57099 >
Date:10:36, 30 September 2009
Author:werdna
Status:ok
Tags:
Comment:
Split out the regex for invalid title characters and sequences so it can be used elsewhere in MediaWiki (will in a moment be used in LiquidThreads).
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -2206,21 +2206,11 @@
22072207 }
22082208 return $p . $name;
22092209 }
2210 -
2211 - /**
2212 - * Secure and split - main initialisation function for this object
2213 - *
2214 - * Assumes that mDbkeyform has been set, and is urldecoded
2215 - * and uses underscores, but not otherwise munged. This function
2216 - * removes illegal characters, splits off the interwiki and
2217 - * namespace prefixes, sets the other forms, and canonicalizes
2218 - * everything.
2219 - * @return \type{\bool} true on success
2220 - */
2221 - private function secureAndSplit() {
2222 - global $wgContLang, $wgLocalInterwiki, $wgCapitalLinks;
2223 -
2224 - # Initialisation
 2210+
 2211+ // Returns a simple regex that will match on characters and sequences invalid in titles.
 2212+ // Note that this doesn't pick up many things that could be wrong with titles, but that
 2213+ // replacing this regex with something valid will make many titles valid.
 2214+ static function getTitleInvalidRegex() {
22252215 static $rxTc = false;
22262216 if( !$rxTc ) {
22272217 # Matching titles will be held as illegal.
@@ -2236,7 +2226,26 @@
22372227 '|&#x[0-9A-Fa-f]+;' .
22382228 '/S';
22392229 }
 2230+
 2231+ return $rxTc;
 2232+ }
22402233
 2234+ /**
 2235+ * Secure and split - main initialisation function for this object
 2236+ *
 2237+ * Assumes that mDbkeyform has been set, and is urldecoded
 2238+ * and uses underscores, but not otherwise munged. This function
 2239+ * removes illegal characters, splits off the interwiki and
 2240+ * namespace prefixes, sets the other forms, and canonicalizes
 2241+ * everything.
 2242+ * @return \type{\bool} true on success
 2243+ */
 2244+ private function secureAndSplit() {
 2245+ global $wgContLang, $wgLocalInterwiki, $wgCapitalLinks;
 2246+
 2247+ # Initialisation
 2248+ $rxTc = self::getTitleInvalidRegex();
 2249+
22412250 $this->mInterwiki = $this->mFragment = '';
22422251 $this->mNamespace = $this->mDefaultNamespace; # Usually NS_MAIN
22432252

Status & tagging log