Fix Special:NewSection showNoRedirectPage form handling (3)
authorDannyS712 <DannyS712.enwiki@gmail.com>
Sat, 10 Aug 2019 23:55:45 +0000 (23:55 +0000)
committerUmherirrender <umherirrender_de.wp@web.de>
Mon, 12 Aug 2019 09:29:52 +0000 (09:29 +0000)
Handle invalid titles by using `newFromTextThrow` and
returning a fatal status if the title is invalid.

Bug: T207577
Change-Id: I2bdfcdbcb7ee41f96122e7f8aa561f6eee34be7b

includes/specials/SpecialNewSection.php

index a24d8cd..c124c14 100644 (file)
@@ -62,7 +62,11 @@ class SpecialNewSection extends RedirectSpecialPage {
 
        public function onFormSubmit( $formData ) {
                $title = $formData['page'];
-               $page = Title::newFromText( $title );
+               try {
+                       $page = Title::newFromTextThrow( $title );
+               } catch ( MalformedTitleException $e ) {
+                       return Status::newFatal( $e->getMessageObject() );
+               }
                $query = [ 'action' => 'edit', 'section' => 'new' ];
                $url = $page->getFullUrlForRedirect( $query );
                $this->getOutput()->redirect( $url );