r68799 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68798‎ | r68799 | r68800 >
Date:22:29, 30 June 2010
Author:simetrical
Status:ok
Tags:
Comment:
Backport r68797 "Disable form validation more thoroughly"

Regression fix, same as r67283. Does not need to be enabled on WMF
because it's only relevant if $wgHtml5 = true. Doesn't need
RELEASE-NOTES, since it's already covered in existing RELEASE-NOTES.
Original commit message:

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:
  • /branches/REL1_16/phase3/includes/Html.php (modified) (history)

Diff [purge]

Index: branches/REL1_16/phase3/includes/Html.php
@@ -143,30 +143,32 @@
144144 # consistency and better compression.
145145 $element = strtolower( $element );
146146
147 - # Remove HTML5-only attributes if we aren't doing HTML5
148 - if ( !$wgHtml5 ) {
149 - if ( $element == 'input' ) {
150 - # Whitelist of valid XHTML1 types
151 - $validTypes = array(
152 - 'hidden',
153 - 'text',
154 - 'password',
155 - 'checkbox',
156 - 'radio',
157 - 'file',
158 - 'submit',
159 - 'image',
160 - 'reset',
161 - 'button',
162 - );
163 - if ( isset( $attribs['type'] )
164 - && !in_array( $attribs['type'], $validTypes ) ) {
165 - # Fall back to type=text, the default
166 - unset( $attribs['type'] );
167 - }
 147+ # Remove HTML5-only attributes if we aren't doing HTML5, and disable
 148+ # form validation regardless (see bug 23769 and the more detailed
 149+ # comment in expandAttributes())
 150+ if ( $element == 'input' ) {
 151+ # Whitelist of types that don't cause validation. All except
 152+ # 'search' are valid in XHTML1.
 153+ $validTypes = array(
 154+ 'hidden',
 155+ 'text',
 156+ 'password',
 157+ 'checkbox',
 158+ 'radio',
 159+ 'file',
 160+ 'submit',
 161+ 'image',
 162+ 'reset',
 163+ 'button',
 164+ 'search',
 165+ );
 166+ if ( isset( $attribs['type'] )
 167+ && !in_array( $attribs['type'], $validTypes ) ) {
 168+ unset( $attribs['type'] );
168169 }
169 - if ( $element == 'textarea' && isset( $attribs['maxlength'] ) ) {
170 - unset( $attribs['maxlength'] );
 170+ if ( isset( $attribs['type'] ) && $attribs['type'] == 'search'
 171+ && !$wgHtml5 ) {
 172+ unset( $attribs['type'] );
171173 }
172174 # Here we're blacklisting some HTML5-only attributes...
173175 $html5attribs = array(
@@ -185,6 +187,9 @@
186188 unset( $attribs[$badAttr] );
187189 }
188190 }
 191+ if ( !$wgHtml5 && $element == 'textarea' && isset( $attribs['maxlength'] ) ) {
 192+ unset( $attribs['maxlength'] );
 193+ }
189194
190195 return "<$element" . self::expandAttributes(
191196 self::dropDefaults( $element, $attribs ) ) . '>';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r67283(bug 23769) Disable HTML5 form validation for now...simetrical17:18, 3 June 2010
r68797Disable form validation more thoroughly...simetrical22:14, 30 June 2010

Status & tagging log