Fix for #837969. Strict rejection of invalid characters in titles is good practice...
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 11 Dec 2003 12:43:13 +0000 (12:43 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 11 Dec 2003 12:43:13 +0000 (12:43 +0000)
includes/Title.php

index 7c840b9..3639be9 100644 (file)
@@ -401,6 +401,14 @@ class Title {
                $this->mInterwiki = $this->mFragment = "";
                $this->mNamespace = 0;
 
+               # Reject illegal characters.
+               #
+               if( preg_match( $rxTc, $this->mDbkeyform ) ) {
+                       return false;
+               }
+
+               # Clean up whitespace
+               #
                $t = preg_replace( "/[\\s_]+/", "_", $this->mDbkeyform );
                if ( "_" == $t{0} ) { 
                        $t = substr( $t, 1 ); 
@@ -455,10 +463,8 @@ class Title {
                        $this->mFragment = substr( $f, 1 );
                        $r = substr( $r, 0, strlen( $r ) - strlen( $f ) );
                }
-               # Strip illegal characters.
-               #
-               $t = preg_replace( $rxTc, "", $r );
 
+               $t = $r;
                if( $this->mInterwiki == "") $t = $wgLang->ucfirst( $t );
                $this->mDbkeyform = $t;
                $this->mUrlform = wfUrlencode( $t );