From aa467dac04905b9d423187d6cda59a98e11b42f2 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Sat, 18 Aug 2018 02:39:36 +0200 Subject: [PATCH] Handle invalid input to Special:FilePath?file= Bug: T175301 Change-Id: I38a05416db10de88f3bc529f5fad9697d7d6e1c2 --- includes/specials/SpecialFilepath.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/includes/specials/SpecialFilepath.php b/includes/specials/SpecialFilepath.php index c18faa12d3..618fd1da48 100644 --- a/includes/specials/SpecialFilepath.php +++ b/includes/specials/SpecialFilepath.php @@ -41,12 +41,17 @@ class SpecialFilepath extends RedirectSpecialPage { public function getRedirect( $par ) { $file = $par ?: $this->getRequest()->getText( 'file' ); + $redirect = null; if ( $file ) { - $argument = "file/$file"; - } else { - $argument = 'file'; + $redirect = SpecialPage::getSafeTitleFor( 'Redirect', "file/$file" ); } - return SpecialPage::getSafeTitleFor( 'Redirect', $argument ); + if ( $redirect === null ) { + // The user input is empty or an invalid title, + // redirect to form of Special:Redirect with the invalid value prefilled + $this->mAddedRedirectParams['wpvalue'] = $file; + $redirect = SpecialPage::getSafeTitleFor( 'Redirect', 'file' ); + } + return $redirect; } protected function getGroupName() { -- 2.20.1