Make WordPress Core


Ignore:
Timestamp:
06/11/2026 10:17:13 PM (3 months ago)
Author:
dmsnell
Message:

HTML API: preserve adjusted foreign attributes on serialization.

Discovered during fuzz-testing of the HTML API. Adjusted foreign attributes, such as xlink:href, were being normalized with a space instead of a colon through ::serialize_token(). This led to the creation of two attributes on output instead of the proper singular attribute.

This patch corrects the issue by ensuring that the attribute namespace and name are separated by a colon when serializing.

Developed in: https://github.com/WordPress/wordpress-develop/pull/12140
Discussed in: https://core.trac.wordpress.org/ticket/65372

Props jonsurrell.
See #65372.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php

    r62439 r62492  
    30713071         * Returns the adjusted attribute name for a given attribute, taking into
    30723072         * account the current parsing context, whether HTML, SVG, or MathML.
     3073         *
     3074         * In SVG and MathML contexts, adjusted foreign attributes with a namespace
     3075         * prefix use a space between the prefix and local name. For example,
     3076         * `xlink:href` is returned as `xlink href`, while the unprefixed `xmlns`
     3077         * attribute is returned as `xmlns`. Non-adjusted attributes with a colon in
     3078         * their name, such as `foo:bar`, are returned unchanged.
    30733079         *
    30743080         * @since 6.7.0
Note: See TracChangeset for help on using the changeset viewer.