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 ) ) . '>';