From 67b17417299331efc246decf64ce60ecde8dff27 Mon Sep 17 00:00:00 2001 From: DannyS712 Date: Sat, 10 Aug 2019 23:55:45 +0000 Subject: [PATCH] Fix Special:NewSection showNoRedirectPage form handling (3) 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/specials/SpecialNewSection.php b/includes/specials/SpecialNewSection.php index a24d8cda69..c124c14f1d 100644 --- a/includes/specials/SpecialNewSection.php +++ b/includes/specials/SpecialNewSection.php @@ -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 ); -- 2.20.1