Make WordPress Core


Ignore:
Timestamp:
02/17/2024 03:26:43 PM (3 years ago)
Author:
swissspidy
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php

    r57563 r57649  
    182182
    183183        /**
     184         * Skips processing the content between tags.
     185         *
     186         * It positions the cursor in the closer tag of the foreign element, if it
     187         * exists.
     188         *
     189         * This function is intended to skip processing SVG and MathML inner content
     190         * instead of bailing out the whole processing.
     191         *
     192         * @since 6.5.0
     193         *
     194         * @access private
     195         *
     196         * @return bool Whether the foreign content was successfully skipped.
     197         */
     198        public function skip_to_tag_closer(): bool {
     199                $depth    = 1;
     200                $tag_name = $this->get_tag();
     201                while ( $depth > 0 && $this->next_tag(
     202                        array(
     203                                'tag_name'    => $tag_name,
     204                                'tag_closers' => 'visit',
     205                        )
     206                ) ) {
     207                        if ( $this->has_self_closing_flag() ) {
     208                                continue;
     209                        }
     210                        $depth += $this->is_tag_closer() ? -1 : 1;
     211                }
     212
     213                return 0 === $depth;
     214        }
     215
     216        /**
    184217         * Finds the matching closing tag for an opening tag.
    185218         *
Note: See TracChangeset for help on using the changeset viewer.