HTML API: Fix nested anchors in MathML text integration points#41
HTML API: Fix nested anchors in MathML text integration points#41sirreal wants to merge 5 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Code reviewFound 1 issue:
wordpress-develop/src/wp-includes/html-api/class-wp-html-processor.php Lines 2925 to 2933 in 779e594 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Scanning breadcrumbs by node name latched onto same-named foreign elements (MathML or SVG A) between the removed HTML anchor and the integration point, storing the wrong depth. The virtual closer then never fired and the stale anchor breadcrumb persisted for the rest of the document. Record the removed node's position in the stack of open elements instead, accounting for the fragment parser's context crumb.
|
Following up on the automated review — one actionable item, nothing blocking. Add a test for a new same-name opener immediately after the subtree closes. The new tests cover the removed outer I ran this; it behaves correctly (the outer wordpress-develop/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php Lines 504 to 506 in 779e594 Worth pinning so a future refactor of those guards can't silently regress it. Minor: the matching in wordpress-develop/src/wp-includes/html-api/class-wp-html-processor.php Lines 910 to 924 in 779e594 |
Note: a nearby integration-point behavior that looks like a bug but is correctWhile fuzzing this branch, the differential oracle flagged this input as a tree mismatch: <h2><math><mi>a</h2><x-0>b</x-0>It is not a bug. The HTML API output matches the spec and Chromium exactly — Why: Live DOM viewer (matches this output): https://software.hixie.ch/utilities/js/live-dom-viewer/?%3Ch2%3E%3Cmath%3E%3Cmi%3Ea%3C%2Fh2%3E%3Cx-0%3Eb%3C%2Fx-0%3E The disagreement came from PHP's Added a regression test pinning this so it can't silently change: |
A heading end tag (</h2>) inside a MathML text integration point (MI) is ignored because MI is a scope boundary, so following content stays inside the integration point rather than becoming a sibling of the heading. This matches the spec and browsers; add a regression test so it can't silently change.
A new A opener immediately after the foreign subtree closes is the one input where the adjusted-current-node guard and the same-name next-event lookahead must cooperate: the removed outer A's virtual closer must fire before the new same-name element opens as a sibling. Add a regression test walking every A visit, and document the identity invariant that the next-event lookahead recovers in the queueing guard.
|
Both items addressed in 10b3976:
|
Summary
Testing
composer installWP_TESTS_SKIP_INSTALL=1 vendor/bin/phpunit --group html-api --filter 'test_reports_nested_anchor_breadcrumbs_inside_mathml_text_integration_point|test_removes_outer_anchor_breadcrumb_after_mathml_text_integration_point_closes|test_visits_outer_anchor_virtual_closer_after_mathml_text_integration_point_closes|test_visits_outer_anchor_virtual_closer_at_end_of_fragment|test_visits_outer_anchor_virtual_closer_before_full_parser_eof_closers'WP_TESTS_SKIP_INSTALL=1 vendor/bin/phpunit --group html-api tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.phpWP_TESTS_SKIP_INSTALL=1 vendor/bin/phpunit --group html-apiWP_TESTS_SKIP_INSTALL=1 vendor/bin/phpunit --group html-api-html5lib-testsvendor/bin/phpcs --standard=phpcs.xml.dist src/wp-includes/html-api/class-wp-html-open-elements.php src/wp-includes/html-api/class-wp-html-processor.php tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.phpgit diff --check trunk..HEADNotes
The original fuzzer replay artifact referenced in the handoff was removed during worktree cleanup, so verification is covered by direct unit regressions for the minimized input and the related fragment/full-parser EOF paths.