From: Martin Urbanec Date: Sat, 13 Jul 2019 22:27:43 +0000 (+0200) Subject: When title contains only slashes, Title::getRootText() shouldn't return false X-Git-Tag: 1.34.0-rc.0~1015^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/modifier.php?a=commitdiff_plain;h=ed1ab4034e39878442fd389b4c1a22161afd935f;p=lhc%2Fweb%2Fwiklou.git When title contains only slashes, Title::getRootText() shouldn't return false Otherwise, Title::makeTitleSafe() will return null, which breaks the assumption that Title::makeTitleSafe() always returns something meaningful for strings returned by Title::getRootText(). Bug: T227816 Change-Id: If79a12bb8d23f1eafc10017d56c62566f39347ad --- diff --git a/includes/Title.php b/includes/Title.php index a956ca2176..7e7153f869 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1770,6 +1770,7 @@ class Title implements LinkTarget, IDBAccessObject { if ( !MediaWikiServices::getInstance()->getNamespaceInfo()-> hasSubpages( $this->mNamespace ) + || strtok( $this->getText(), '/' ) === false ) { return $this->getText(); } diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index 4ffef02d19..5ecc663481 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -553,6 +553,10 @@ class TitleTest extends MediaWikiTestCase { # Title, expected base, optional message [ 'User:John_Doe/subOne/subTwo', 'John Doe' ], [ 'User:Foo / Bar / Baz', 'Foo ' ], + [ 'Talk:////', '////' ], + [ 'Template:////', '////' ], + [ 'Template:Foo////', 'Foo' ], + [ 'Template:Foo////Bar', 'Foo' ], ]; }