Handle invalid input to Special:FilePath?file=
authorUmherirrender <umherirrender_de.wp@web.de>
Sat, 18 Aug 2018 00:39:36 +0000 (02:39 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Sun, 16 Sep 2018 19:46:56 +0000 (19:46 +0000)
Bug: T175301
Change-Id: I38a05416db10de88f3bc529f5fad9697d7d6e1c2

includes/specials/SpecialFilepath.php

index c18faa1..618fd1d 100644 (file)
@@ -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() {