From 76a543ea30f99b5ea83cc98533e31a9c681f347c Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Wed, 30 Jun 2010 22:14:36 +0000 Subject: [PATCH] Disable form validation more thoroughly Expands on r67283 by not using any HTML5 input types either, except search. Otherwise you'd still have problems when changing integer fields in Special:Preferences, say. Sad, since in Opera it had a cute little widget for incrementing/decrementing, and types like email have some neat effects on platforms like the iPhone (see ). But there's no other way to disable the constraints these impose without using JS, and given how broken WebKit is right now . . . --- includes/Html.php | 51 ++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/includes/Html.php b/includes/Html.php index 6fe6da83d6..76abf38c15 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -155,32 +155,37 @@ class Html { return ''; } - # Remove HTML5-only attributes if we aren't doing HTML5 - if ( !$wgHtml5 ) { - if ( $element == 'input' ) { - # Whitelist of valid XHTML1 types - $validTypes = array( - 'hidden', - 'text', - 'password', - 'checkbox', - 'radio', - 'file', - 'submit', - 'image', - 'reset', - 'button', - ); - if ( isset( $attribs['type'] ) - && !in_array( $attribs['type'], $validTypes ) ) { - # Fall back to type=text, the default - unset( $attribs['type'] ); - } + # Remove HTML5-only attributes if we aren't doing HTML5, and disable + # form validation regardless (see bug 23769 and the more detailed + # comment in expandAttributes()) + if ( $element == 'input' ) { + # Whitelist of types that don't cause validation. All except + # 'search' are valid in XHTML1. + $validTypes = array( + 'hidden', + 'text', + 'password', + 'checkbox', + 'radio', + 'file', + 'submit', + 'image', + 'reset', + 'button', + 'search', + ); + if ( isset( $attribs['type'] ) + && !in_array( $attribs['type'], $validTypes ) ) { + unset( $attribs['type'] ); } - if ( $element == 'textarea' && isset( $attribs['maxlength'] ) ) { - unset( $attribs['maxlength'] ); + if ( isset( $attribs['type'] ) && $attribs['type'] == 'search' + && !$wgHtml5 ) { + unset( $attribs['type'] ); } } + if ( !$wgHtml5 && $element == 'textarea' && isset( $attribs['maxlength'] ) ) { + unset( $attribs['maxlength'] ); + } return "<$element" . self::expandAttributes( self::dropDefaults( $element, $attribs ) ) . '>'; -- 2.20.1