@@ -1719,39 +1719,38 @@ public function data_next_tag_ignores_script_tag_contents() {
17191719 *
17201720 * See https://html.spec.whatwg.org/#parse-error-invalid-first-character-of-tag-name
17211721 *
1722+ * @ticket 58007
17221723 * @dataProvider data_next_tag_ignores_invalid_first_character_of_tag_name_comments
17231724 *
1724- * @param $html_with_markers
1725- * @param $before_tag
1726- * @param $after_tag
1727- * @return void
1725+ * @param string $html_with_markers HTML containing an invalid tag closer whose element before and element after contain the "start" and "end" CSS classes.
17281726 */
1729- public function test_next_tag_ignores_invalid_first_character_of_tag_name_comments ( $ html_with_markers, $ before_tag , $ after_tag ) {
1727+ public function test_next_tag_ignores_invalid_first_character_of_tag_name_comments ( $ html_with_markers ) {
17301728 $ p = new WP_HTML_Tag_Processor ( $ html_with_markers );
1731- $ p ->next_tag ( $ before_tag );
1729+ $ p ->next_tag ( array ( ' class_name ' => ' start ' ) );
17321730 $ p ->next_tag ();
17331731
1734- $ this ->assertSame ( $ after_tag , $ p ->get_tag ( ) );
1732+ $ this ->assertSame ( ' end ' , $ p ->get_attribute ( ' class ' ) );
17351733 }
17361734
1735+ /**
1736+ * Data provider.
1737+ *
1738+ * @ticket 58007
1739+ *
1740+ * @return array[]
1741+ */
17371742 public function data_next_tag_ignores_invalid_first_character_of_tag_name_comments () {
17381743 return array (
17391744 'Invalid tag openers as normal text ' => array (
1740- '<ul><li><div>I <3 when outflow > inflow</div><img></li></ul> ' ,
1741- 'DIV ' ,
1742- 'IMG ' ,
1745+ '<ul><li><div class=start>I <3 when outflow > inflow</div><img class=end></li></ul> ' ,
17431746 ),
17441747
17451748 'Invalid tag closers as comments ' => array (
1746- '<ul><li><div>I </3 when <img> outflow <br> inflow</div></li></ul> ' ,
1747- 'DIV ' ,
1748- 'BR ' ,
1749+ '<ul><li><div class=start>I </3 when <img> outflow <br class=end> inflow</div></li></ul> ' ,
17491750 ),
17501751
17511752 'Unexpected question mark instead of tag name ' => array (
1752- '<div><?xml-stylesheet type="text/css" href="style.css"?><hr> ' ,
1753- 'DIV ' ,
1754- 'HR ' ,
1753+ '<div class=start><?xml-stylesheet type="text/css" href="style.css"?><hr class=end> ' ,
17551754 ),
17561755 );
17571756 }
@@ -1808,6 +1807,13 @@ public function data_next_tag_ignores_contents_of_rcdata_tag() {
18081807 );
18091808 }
18101809
1810+ /**
1811+ * Ensures that the invalid comment closing syntax "--!>" properly closes a comment.
1812+ *
1813+ * @ticket 58007
1814+ * @covers WP_HTML_Tag_Processor::next_tag
1815+ *
1816+ */
18111817 public function test_allows_incorrectly_closed_comments () {
18121818 $ p = new WP_HTML_Tag_Processor ( '<img id=before><!-- <img id=inside> --!><img id=after>--><img id=final> ' );
18131819
@@ -1822,19 +1828,29 @@ public function test_allows_incorrectly_closed_comments() {
18221828 }
18231829
18241830 /**
1831+ * Ensures that abruptly-closed empty comments are properly closed.
1832+ *
1833+ * @ticket 58007
1834+ * @covers WP_HTML_Tag_Processor::next_tag
18251835 * @dataProvider data_abruptly_closed_empty_comments
18261836 *
1827- * @param $html
1828- * @return void
1837+ * @param string $html_with_after_marker HTML to test with "id=after" on element immediately following an abruptly closed comment.
18291838 */
1830- public function test_closes_abrupt_closing_of_empty_comment ( $ html ) {
1831- $ p = new WP_HTML_Tag_Processor ( $ html );
1839+ public function test_closes_abrupt_closing_of_empty_comment ( $ html_with_after_marker ) {
1840+ $ p = new WP_HTML_Tag_Processor ( $ html_with_after_marker );
18321841 $ p ->next_tag ();
18331842 $ p ->next_tag ();
18341843
18351844 $ this ->assertSame ( 'after ' , $ p ->get_attribute ( 'id ' ), 'Did not find tag after closing abruptly-closed comment ' );
18361845 }
18371846
1847+ /**
1848+ * Data provider.
1849+ *
1850+ * @ticket 58007
1851+ *
1852+ * @return array[]
1853+ */
18381854 public function data_abruptly_closed_empty_comments () {
18391855 return array (
18401856 'Empty comment with two dashes only ' => array ( '<hr><!--><hr id=after> ' ),
0 commit comments