From ed1ab4034e39878442fd389b4c1a22161afd935f Mon Sep 17 00:00:00 2001 From: Martin Urbanec Date: Sun, 14 Jul 2019 00:27:43 +0200 Subject: [PATCH] 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 --- includes/Title.php | 1 + tests/phpunit/includes/TitleTest.php | 4 ++++ 2 files changed, 5 insertions(+) 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' ], ]; } -- 2.20.1