From: Brion Vibber Date: Sun, 16 Jan 2005 08:46:24 +0000 (+0000) Subject: * Don't try to create links without namespaces ([[Category:]] link bug) X-Git-Tag: 1.5.0alpha1~921 X-Git-Url: http://git.cyclocoop.org/data/Fool?a=commitdiff_plain;h=add13d19b8e767218f84bcb951d781c50d4c5856;p=lhc%2Fweb%2Fwiklou.git * Don't try to create links without namespaces ([[Category:]] link bug) --- diff --git a/includes/Title.php b/includes/Title.php index 167d406340..7e32e6bf9b 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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 ); diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index 2e945235f9..dcb788747f 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -1796,6 +1796,24 @@ http://en.wikinews.org/wiki/Wikinews:Workplace !!end +!! test +Namespaced link must have a title +!! input +[[Project:]] +!! result +

[[Project:]] +

+!!end + +!! test +Namespaced link must have a title (bad fragment version) +!! input +[[Project:#fragment]] +!! result +

[[Project:#fragment]] +

+!!end + TODO: more images more tables