Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4243,12 +4243,8 @@ private function step_in_foreign_content(): bool {
/*
* > Acknowledge the token's self-closing flag, and then act as
* > described in the steps for a "script" end tag below.
*
* @todo Verify that this shouldn't be handled by the rule for
* "An end tag whose name is 'script', if the current node
* is an SVG script element."
*/
goto in_foreign_content_any_other_end_tag;
goto in_foreign_content_svg_script_close_tag;
} else {
$this->state->stack_of_open_elements->pop();
}
Expand All @@ -4260,14 +4256,15 @@ private function step_in_foreign_content(): bool {
* > An end tag whose name is "script", if the current node is an SVG script element.
*/
if ( $this->is_tag_closer() && 'SCRIPT' === $this->state->current_token->node_name && 'svg' === $this->state->current_token->namespace ) {
in_foreign_content_svg_script_close_tag:
$this->state->stack_of_open_elements->pop();
return true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a fall-through to the next conditional block that I believe was unintentional. Typically, we expect to enter a single block.

}

/*
* > Any other end tag
*/
if ( $this->is_tag_closer() ) {
in_foreign_content_any_other_end_tag:
$node = $this->state->stack_of_open_elements->current_node();
if ( $tag_name !== $node->node_name ) {
// @todo Indicate a parse error once it's possible.
Expand Down
8 changes: 8 additions & 0 deletions tests/phpunit/tests/html-api/wpHtmlProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,4 +503,12 @@ public function __construct( $html ) {
$subclass_processor = call_user_func( array( get_class( $subclass_instance ), 'create_fragment' ), '' );
$this->assertInstanceOf( get_class( $subclass_instance ), $subclass_processor, '::create_fragment did not return subclass instance.' );
}

/**
* @ticket 61576
*/
public function test_foreign_content_script_self_closing() {
$processor = WP_HTML_Processor::create_fragment( '<svg><script />' );
$this->assertTrue( $processor->next_tag( 'script' ) );
}
}