Index: branches/REL1_16/phase3/includes/Html.php |
— | — | @@ -143,30 +143,32 @@ |
144 | 144 | # consistency and better compression. |
145 | 145 | $element = strtolower( $element ); |
146 | 146 | |
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'] ); |
168 | 169 | } |
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'] ); |
171 | 173 | } |
172 | 174 | # Here we're blacklisting some HTML5-only attributes... |
173 | 175 | $html5attribs = array( |
— | — | @@ -185,6 +187,9 @@ |
186 | 188 | unset( $attribs[$badAttr] ); |
187 | 189 | } |
188 | 190 | } |
| 191 | + if ( !$wgHtml5 && $element == 'textarea' && isset( $attribs['maxlength'] ) ) { |
| 192 | + unset( $attribs['maxlength'] ); |
| 193 | + } |
189 | 194 | |
190 | 195 | return "<$element" . self::expandAttributes( |
191 | 196 | self::dropDefaults( $element, $attribs ) ) . '>'; |