| | 2041 | /** |
| | 2042 | * @ticket 58637 |
| | 2043 | * |
| | 2044 | * @covers WP_HTML_Tag_Processor::next_tag |
| | 2045 | * |
| | 2046 | * @dataProvider data_incomplete_syntax_elements |
| | 2047 | * |
| | 2048 | * @param string $incomplete_html HTML text containing some kind of incomplete syntax. |
| | 2049 | */ |
| | 2050 | public function test_returns_false_for_incomplete_syntax_elements( $incomplete_html ) { |
| | 2051 | $p = new WP_HTML_Tag_Processor( $incomplete_html ); |
| | 2052 | $this->assertFalse( $p->next_tag() ); |
| | 2053 | } |
| | 2054 | |
| | 2055 | /** |
| | 2056 | * Data provider. |
| | 2057 | * |
| | 2058 | * @return array[] |
| | 2059 | */ |
| | 2060 | public function data_incomplete_syntax_elements() { |
| | 2061 | return array( |
| | 2062 | 'No tags' => array( 'this is nothing more than a text node' ), |
| | 2063 | 'Incomplete tag name' => array( '<swit' ), |
| | 2064 | 'Incomplete tag (no attributes)' => array( '<div' ), |
| | 2065 | 'Incomplete tag (attributes)' => array( '<div inert title="test"' ), |
| | 2066 | 'Incomplete attribute (unquoted)' => array( '<button disabled' ), |
| | 2067 | 'Incomplete attribute (single quoted)' => array( "<li class='just-another class" ), |
| | 2068 | 'Incomplete attribute (double quoted)' => array( '<iframe src="https://www.example.com/embed/abcdef' ), |
| | 2069 | 'Incomplete comment (normative)' => array( '<!-- without end' ), |
| | 2070 | 'Incomplete comment (missing --)' => array( '<!-- without end --' ), |
| | 2071 | 'Incomplete comment (--!)' => array( '<!-- without end --!' ), |
| | 2072 | 'Incomplete comment (bogus comment)' => array( '</3 is not a tag' ), |
| | 2073 | 'Incomplete DOCTYPE' => array( '<!DOCTYPE html' ), |
| | 2074 | 'Partial DOCTYPE' => array( '<!DOCTY' ), |
| | 2075 | 'Incomplete CDATA' => array( '<[CDATA[something inside of here needs to get out' ), |
| | 2076 | 'Partial CDATA' => array( '<[CDA' ), |
| | 2077 | 'Partially closed CDATA]' => array( '<[CDATA[cannot escape]' ), |
| | 2078 | 'Partially closed CDATA]>' => array( '<[CDATA[cannot escape]>' ), |
| | 2079 | ); |
| | 2080 | } |
| | 2081 | |