Skip to content

Commit 78ef4f7

Browse files
committed
HTML API: Support INPUT tags.
Adds support for the following HTML elements to the HTML Processor: - INPUT Previously this element was not supported and the HTML Processor would bail when encountering one. Now, with this patch applied, it will proceed to parse the HTML document. Developed in #5907 Discussed in https://core.trac.wordpress.org/ticket/60283 Props jonsurrell See #60283 git-svn-id: https://develop.svn.wordpress.org/trunk@57343 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 86d4ac2 commit 78ef4f7

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,18 @@
101101
*
102102
* - Containers: ADDRESS, BLOCKQUOTE, DETAILS, DIALOG, DIV, FOOTER, HEADER, MAIN, MENU, SPAN, SUMMARY.
103103
* - Custom elements: All custom elements are supported. :)
104-
* - Form elements: BUTTON, DATALIST, FIELDSET, LABEL, LEGEND, METER, PROGRESS, SEARCH.
104+
* - Form elements: BUTTON, DATALIST, FIELDSET, INPUT, LABEL, LEGEND, METER, PROGRESS, SEARCH.
105105
* - Formatting elements: B, BIG, CODE, EM, FONT, I, PRE, SMALL, STRIKE, STRONG, TT, U, WBR.
106106
* - Heading elements: H1, H2, H3, H4, H5, H6, HGROUP.
107107
* - Links: A.
108-
* - Lists: DD, DL, DT, LI, OL, LI.
109-
* - Media elements: AUDIO, CANVAS, EMBED, FIGCAPTION, FIGURE, IMG, MAP, PARAM, PICTURE, SOURCE, VIDEO, TRACK.
108+
* - Lists: DD, DL, DT, LI, OL, UL.
109+
* - Media elements: AUDIO, CANVAS, EMBED, FIGCAPTION, FIGURE, IMG, MAP, PICTURE, SOURCE, TRACK, VIDEO.
110110
* - Paragraph: BR, P.
111-
* - Phrasing elements: AREA, ABBR, BDI, BDO, CITE, DATA, DEL, DFN, INS, MARK, OUTPUT, Q, SAMP, SUB, SUP, TIME, VAR.
111+
* - Phrasing elements: ABBR, AREA, BDI, BDO, CITE, DATA, DEL, DFN, INS, MARK, OUTPUT, Q, SAMP, SUB, SUP, TIME, VAR.
112112
* - Sectioning elements: ARTICLE, ASIDE, HR, NAV, SECTION.
113113
* - Templating elements: SLOT.
114114
* - Text decoration: RUBY.
115-
* - Deprecated elements: ACRONYM, BLINK, CENTER, DIR, ISINDEX, KEYGEN, LISTING, MULTICOL, NEXTID, SPACER.
115+
* - Deprecated elements: ACRONYM, BLINK, CENTER, DIR, ISINDEX, KEYGEN, LISTING, MULTICOL, NEXTID, PARAM, SPACER.
116116
*
117117
* ### Supported markup
118118
*
@@ -972,6 +972,23 @@ private function step_in_body() {
972972
$this->state->frameset_ok = false;
973973
return true;
974974

975+
/*
976+
* > A start tag whose tag name is "input"
977+
*/
978+
case '+INPUT':
979+
$this->reconstruct_active_formatting_elements();
980+
$this->insert_html_element( $this->state->current_token );
981+
$type_attribute = $this->get_attribute( 'type' );
982+
/*
983+
* > If the token does not have an attribute with the name "type", or if it does,
984+
* > but that attribute's value is not an ASCII case-insensitive match for the
985+
* > string "hidden", then: set the frameset-ok flag to "not ok".
986+
*/
987+
if ( ! is_string( $type_attribute ) || 'hidden' !== strtolower( $type_attribute ) ) {
988+
$this->state->frameset_ok = false;
989+
}
990+
return true;
991+
975992
/*
976993
* > A start tag whose tag name is "hr"
977994
*/
@@ -1024,7 +1041,6 @@ private function step_in_body() {
10241041
case 'HEAD':
10251042
case 'HTML':
10261043
case 'IFRAME':
1027-
case 'INPUT':
10281044
case 'LINK':
10291045
case 'MARQUEE':
10301046
case 'MATH':

tests/phpunit/tests/html-api/wpHtmlProcessor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ public function data_unsupported_special_in_body_tags() {
253253
'HEAD' => array( 'HEAD' ),
254254
'HTML' => array( 'HTML' ),
255255
'IFRAME' => array( 'IFRAME' ),
256-
'INPUT' => array( 'INPUT' ),
257256
'LINK' => array( 'LINK' ),
258257
'MARQUEE' => array( 'MARQUEE' ),
259258
'MATH' => array( 'MATH' ),

tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ public function data_unsupported_elements() {
180180
'HEAD',
181181
'HTML',
182182
'IFRAME',
183-
'INPUT',
184183
'LINK',
185184
'MARQUEE', // Deprecated.
186185
'MATH',

0 commit comments

Comments
 (0)