r68797 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68796‎ | r68797 | r68798 >
Date:22:14, 30 June 2010
Author:simetrical
Status:ok
Tags:
Comment:
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
<http://diveintohtml5.org/forms.html#type-email&gt;). But there's no other
way to disable the constraints these impose without using JS, and given
how broken WebKit is right now . . .
Modified paths:
  • /trunk/phase3/includes/Html.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Html.php
@@ -155,32 +155,37 @@
156156 return '';
157157 }
158158
159 - # Remove HTML5-only attributes if we aren't doing HTML5
160 - if ( !$wgHtml5 ) {
161 - if ( $element == 'input' ) {
162 - # Whitelist of valid XHTML1 types
163 - $validTypes = array(
164 - 'hidden',
165 - 'text',
166 - 'password',
167 - 'checkbox',
168 - 'radio',
169 - 'file',
170 - 'submit',
171 - 'image',
172 - 'reset',
173 - 'button',
174 - );
175 - if ( isset( $attribs['type'] )
176 - && !in_array( $attribs['type'], $validTypes ) ) {
177 - # Fall back to type=text, the default
178 - unset( $attribs['type'] );
179 - }
 159+ # Remove HTML5-only attributes if we aren't doing HTML5, and disable
 160+ # form validation regardless (see bug 23769 and the more detailed
 161+ # comment in expandAttributes())
 162+ if ( $element == 'input' ) {
 163+ # Whitelist of types that don't cause validation. All except
 164+ # 'search' are valid in XHTML1.
 165+ $validTypes = array(
 166+ 'hidden',
 167+ 'text',
 168+ 'password',
 169+ 'checkbox',
 170+ 'radio',
 171+ 'file',
 172+ 'submit',
 173+ 'image',
 174+ 'reset',
 175+ 'button',
 176+ 'search',
 177+ );
 178+ if ( isset( $attribs['type'] )
 179+ && !in_array( $attribs['type'], $validTypes ) ) {
 180+ unset( $attribs['type'] );
180181 }
181 - if ( $element == 'textarea' && isset( $attribs['maxlength'] ) ) {
182 - unset( $attribs['maxlength'] );
 182+ if ( isset( $attribs['type'] ) && $attribs['type'] == 'search'
 183+ && !$wgHtml5 ) {
 184+ unset( $attribs['type'] );
183185 }
184186 }
 187+ if ( !$wgHtml5 && $element == 'textarea' && isset( $attribs['maxlength'] ) ) {
 188+ unset( $attribs['maxlength'] );
 189+ }
185190
186191 return "<$element" . self::expandAttributes(
187192 self::dropDefaults( $element, $attribs ) ) . '>';

Follow-up revisions

RevisionCommit summaryAuthorDate
r68799Backport r68797 "Disable form validation more thoroughly"...simetrical22:29, 30 June 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r67283(bug 23769) Disable HTML5 form validation for now...simetrical17:18, 3 June 2010

Status & tagging log