Fix invalid namespace restriction when js is disabled
authorDayllan Maza <dmaza@wikimedia.org>
Thu, 28 Mar 2019 20:02:44 +0000 (16:02 -0400)
committerDmaza <dmaza@wikimedia.org>
Fri, 29 Mar 2019 19:15:56 +0000 (19:15 +0000)
When JS is disabled on Special:Block you were able to specify
any namespace as part of the namespace restrictions field. This patch
rejects any virtual namespace submitted on that field

Bug: T216831
Change-Id: If09c43e5f836e1fdd9438b856d7f44f434c29fe1

includes/htmlform/fields/HTMLNamespacesMultiselectField.php

index 5ad1a4d..bd492d1 100644 (file)
@@ -45,6 +45,10 @@ class HTMLNamespacesMultiselectField extends HTMLSelectNamespace {
                }
 
                foreach ( $namespaces as $namespace ) {
+                       if ( $namespace < 0 ) {
+                               return $this->msg( 'htmlform-select-badoption' );
+                       }
+
                        $result = parent::validate( $namespace, $alldata );
                        if ( $result !== true ) {
                                return $result;