mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Interactivity API: Skip instead of bail out if HTML contains SVG or MATH.
Addresses an issue with server-side processing of directives when there is e.g. an SVG icon a navigation menu. Props cbravobernal, westonruter, dmsnell, swissspidy. Fixes #60517. git-svn-id: https://develop.svn.wordpress.org/trunk@57649 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -180,6 +180,39 @@ final class WP_Interactivity_API_Directives_Processor extends WP_HTML_Tag_Proces
|
||||
return array( $opener_tag, $closer_tag );
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips processing the content between tags.
|
||||
*
|
||||
* It positions the cursor in the closer tag of the foreign element, if it
|
||||
* exists.
|
||||
*
|
||||
* This function is intended to skip processing SVG and MathML inner content
|
||||
* instead of bailing out the whole processing.
|
||||
*
|
||||
* @since 6.5.0
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @return bool Whether the foreign content was successfully skipped.
|
||||
*/
|
||||
public function skip_to_tag_closer(): bool {
|
||||
$depth = 1;
|
||||
$tag_name = $this->get_tag();
|
||||
while ( $depth > 0 && $this->next_tag(
|
||||
array(
|
||||
'tag_name' => $tag_name,
|
||||
'tag_closers' => 'visit',
|
||||
)
|
||||
) ) {
|
||||
if ( $this->has_self_closing_flag() ) {
|
||||
continue;
|
||||
}
|
||||
$depth += $this->is_tag_closer() ? -1 : 1;
|
||||
}
|
||||
|
||||
return 0 === $depth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the matching closing tag for an opening tag.
|
||||
*
|
||||
|
||||
@@ -235,9 +235,14 @@ final class WP_Interactivity_API {
|
||||
while ( $p->next_tag( array( 'tag_closers' => 'visit' ) ) ) {
|
||||
$tag_name = $p->get_tag();
|
||||
|
||||
/*
|
||||
* Directives inside SVG and MATH tags are not processed,
|
||||
* as they are not compatible with the Tag Processor yet.
|
||||
* We still process the rest of the HTML.
|
||||
*/
|
||||
if ( 'SVG' === $tag_name || 'MATH' === $tag_name ) {
|
||||
$unbalanced = true;
|
||||
break;
|
||||
$p->skip_to_tag_closer();
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $p->is_tag_closer() ) {
|
||||
|
||||
Reference in New Issue
Block a user