Skip to content

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented Sep 2, 2024

Fix a bug where a switch statement break should break the switch and the surrounding foreach loop to satisfy these conditions in the standard:

A start tag whose tag name is "a"
If the list of active formatting elements contains an a element between the end of the list and the last marker on the list (or the start of the list if there is no marker on the list), then this is a parse error; run the adoption agency algorithm for the token, then remove that element from the list of active formatting elements and the stack of open elements if the adoption agency algorithm didn't already remove it (it might not have if the element is not in table scope).

Markers and an A element should break out of the loop that. As implemented now, the forEach will always continue up to the root.

Trac ticket:


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@sirreal sirreal changed the title HTML API: Fix off-by-one active formatting removal HTML API: Fix A tag active formatting element loop missing break Sep 2, 2024
@sirreal sirreal marked this pull request as ready for review September 2, 2024 14:17
@sirreal
Copy link
Member Author

sirreal commented Sep 2, 2024

@dmsnell for your review.

Copy link

github-actions bot commented Sep 2, 2024

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jonsurrell.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@sirreal
Copy link
Member Author

sirreal commented Sep 2, 2024

A good test for this is this HTML:

<i><a><table><td><a>

The table creates a marker so the second a tag should not reach the first a tag in the loop. The adoption agency algorithm should not be run (which will always fails in this case).

This currently fails on nightly, but works correctly on this PR.

Copy link

github-actions bot commented Sep 2, 2024

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

pento pushed a commit that referenced this pull request Sep 2, 2024
A mistake in the original code handling opening A elements in the HTML Processor led to mistakes in parsing where the Processor would bail in situations when it could have proceeded. While this was errant behavior, it didn't violate the public contract since it would bail in these situations.

This patch fixes the mistake, which was to only break out of the innermost loop instead of breaking from the containing loop, which resolves the issue.

Developed in #7281
Discussed in https://core.trac.wordpress.org/ticket/61576

Follow-up to [56274].

Props jonsurrell.
See #61576.


git-svn-id: https://develop.svn.wordpress.org/trunk@58966 602fd350-edb4-49c9-b593-d223f7449a82
@dmsnell
Copy link
Member

dmsnell commented Sep 2, 2024

Merged in [58966]
9bf0448

@sirreal I've folded this into Core-61576 even though it was a bug introduced with the original HTML Processor because the error behavior was to bail instead of return an invalid parse. If you think this is wrong we can re-classify, but it felt appropriate when I examined it.

@dmsnell dmsnell closed this Sep 2, 2024
@dmsnell
Copy link
Member

dmsnell commented Sep 2, 2024

This leads me to wonder if some of the failure cases I've seen, which proliferate around A elements, was actually due to this bug instead of hitting an unsupported clause in the active format reconstruction work.

markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Sep 2, 2024
A mistake in the original code handling opening A elements in the HTML Processor led to mistakes in parsing where the Processor would bail in situations when it could have proceeded. While this was errant behavior, it didn't violate the public contract since it would bail in these situations.

This patch fixes the mistake, which was to only break out of the innermost loop instead of breaking from the containing loop, which resolves the issue.

Developed in WordPress/wordpress-develop#7281
Discussed in https://core.trac.wordpress.org/ticket/61576

Follow-up to [56274].

Props jonsurrell.
See #61576.

Built from https://develop.svn.wordpress.org/trunk@58966


git-svn-id: http://core.svn.wordpress.org/trunk@58362 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Sep 2, 2024
A mistake in the original code handling opening A elements in the HTML Processor led to mistakes in parsing where the Processor would bail in situations when it could have proceeded. While this was errant behavior, it didn't violate the public contract since it would bail in these situations.

This patch fixes the mistake, which was to only break out of the innermost loop instead of breaking from the containing loop, which resolves the issue.

Developed in WordPress/wordpress-develop#7281
Discussed in https://core.trac.wordpress.org/ticket/61576

Follow-up to [56274].

Props jonsurrell.
See #61576.

Built from https://develop.svn.wordpress.org/trunk@58966


git-svn-id: https://core.svn.wordpress.org/trunk@58362 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@sirreal sirreal deleted the html-api/fix-active-format-removal-offby1 branch September 3, 2024 08:00
@sirreal
Copy link
Member Author

sirreal commented Sep 3, 2024

This leads me to wonder if some of the failure cases I've seen, which proliferate around A elements, was actually due to this bug instead of hitting an unsupported clause in the active format reconstruction work.

Yes, I believe some test failures around active format reconstruction were a result of this bug. I struggled with it when debugging some of the active format reconstruction and that was where I discovered this.

aslamdoctor pushed a commit to aslamdoctor/wordpress-develop that referenced this pull request Dec 28, 2024
A mistake in the original code handling opening A elements in the HTML Processor led to mistakes in parsing where the Processor would bail in situations when it could have proceeded. While this was errant behavior, it didn't violate the public contract since it would bail in these situations.

This patch fixes the mistake, which was to only break out of the innermost loop instead of breaking from the containing loop, which resolves the issue.

Developed in WordPress#7281
Discussed in https://core.trac.wordpress.org/ticket/61576

Follow-up to [56274].

Props jonsurrell.
See #61576.


git-svn-id: https://develop.svn.wordpress.org/trunk@58966 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants