* Don't try to create links without namespaces ([[Category:]] link bug)
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 16 Jan 2005 08:46:24 +0000 (08:46 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 16 Jan 2005 08:46:24 +0000 (08:46 +0000)
includes/Title.php
maintenance/parserTests.txt

index 167d406..7e32e6b 100644 (file)
@@ -1182,6 +1182,7 @@ class Title {
                # We shouldn't need to query the DB for the size.
                #$maxSize = $dbr->textFieldSize( 'page', 'page_title' );
                if ( strlen( $r ) > 255 ) {
+                       wfProfileOut( $fname );
                        return false;
                }
 
@@ -1199,6 +1200,18 @@ class Title {
                        $t = $r;
                }
                
+               /**
+                * Can't make a link to a namespace alone...
+                * "empty" local links can only be self-links
+                * with a fragment identifier.
+                */
+               if( $t == '' &&
+                       $this->mInterwiki == '' &&
+                       $this->mNamespace != NS_MAIN ) {
+                       wfProfileOut( $fname );
+                       return false;
+               }
+               
                # Fill fields
                $this->mDbkeyform = $t;
                $this->mUrlform = wfUrlencode( $t );
index 2e94523..dcb7887 100644 (file)
@@ -1796,6 +1796,24 @@ http://en.wikinews.org/wiki/Wikinews:Workplace
 !!end
 
 
+!! test
+Namespaced link must have a title
+!! input
+[[Project:]]
+!! result
+<p>[[Project:]]
+</p>
+!!end
+
+!! test
+Namespaced link must have a title (bad fragment version)
+!! input
+[[Project:#fragment]]
+!! result
+<p>[[Project:#fragment]]
+</p>
+!!end
+
 TODO:
 more images
 more tables