Merge "mediawiki.Uri.test: Clean up"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 8 Dec 2012 13:16:31 +0000 (13:16 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 8 Dec 2012 13:16:31 +0000 (13:16 +0000)
includes/Html.php
includes/SpecialPage.php
tests/phpunit/includes/HtmlTest.php

index 2ab6069..14456e4 100644 (file)
@@ -476,7 +476,13 @@ class Html {
                        // server-side validation.  Opera is the only other implementation at
                        // this time, and has ugly UI, so just kill the feature entirely until
                        // we have at least one good implementation.
-                       if ( in_array( $key, array( 'max', 'min', 'pattern', 'required', 'step' ) ) ) {
+
+                       // As the default value of "1" for "step" rejects decimal
+                       // numbers to be entered in 'type="number"' fields, allow
+                       // the special case 'step="any"'.
+
+                       if ( in_array( $key, array( 'max', 'min', 'pattern', 'required' ) ) ||
+                                $key === 'step' && $value !== 'any' ) {
                                continue;
                        }
 
index 67aa2b3..e844d93 100644 (file)
@@ -254,13 +254,14 @@ class SpecialPage {
         *
         * @param $name String
         * @param $subpage String|Bool subpage string, or false to not use a subpage
+        * @param $fragment String the link fragment (after the "#")
         * @throws MWException
         * @return Title object
         */
-       public static function getTitleFor( $name, $subpage = false ) {
+       public static function getTitleFor( $name, $subpage = false, $fragment = '' ) {
                $name = SpecialPageFactory::getLocalNameFor( $name, $subpage );
                if ( $name ) {
-                       return Title::makeTitle( NS_SPECIAL, $name );
+                       return Title::makeTitle( NS_SPECIAL, $name, $fragment );
                } else {
                        throw new MWException( "Invalid special page name \"$name\"" );
                }
index 65dd924..47fa5f4 100644 (file)
@@ -605,4 +605,16 @@ class HtmlTest extends MediaWikiTestCase {
                return $ret;
        }
 
+       public function testFormValidationBlacklist() {
+               $this->assertEmpty(
+                       Html::expandAttributes( array( 'min' => 1, 'max' => 100, 'pattern' => 'abc', 'required' => true, 'step' => 2 ) ),
+                       'Blacklist form validation attributes.'
+               );
+               $this->assertEquals(
+                       ' step=any',
+                       Html::expandAttributes( array( 'min' => 1, 'max' => 100, 'pattern' => 'abc', 'required' => true, 'step' => 'any' ) ),
+                       'Allow special case "step=any".'
+               );
+       }
+
 }