Skip to content

Conversation

@sirreal
Copy link
Member

@sirreal sirreal commented Jul 10, 2025

Trac ticket: Core-63738

Simplify META tag handling with regards to encoding confidence.

With any of the standard HTML Processor creation paths (WP_HTML_Processor::create_fragment() and WP_HTML_Processor::create_full_parser()), the encoding is never set to tentative. It is either irrelevant (on fragments) or certain on full parsers. In both cases, only the UTF-8 encoding is supported.

This is an optimization to lift a necessary condition to the top level and avoid processing in the case we expect to encounter in almost every case.


Fragments follow this path to set irrelevant:

return $context_processor->create_fragment_at_current_node( $html );

$fragment_processor->state->encoding_confidence = 'irrelevant';

And full parsers set certain here:

$processor->state->encoding_confidence = 'certain';

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.

@github-actions
Copy link

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.

@sirreal sirreal force-pushed the html-api/simplify-meta-tag-encoding-handling branch from 86e40c4 to 77aadec Compare July 22, 2025 12:56
Copy link
Member

@dmsnell dmsnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some notes to make the versions all concrete. after that I think this is ready to go.

@sirreal sirreal marked this pull request as ready for review July 23, 2025 19:11
@github-actions
Copy link

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, dmsnell.

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

Copy link
Member

@dmsnell dmsnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ready. At some point we can benchmark it.

@sirreal sirreal force-pushed the html-api/simplify-meta-tag-encoding-handling branch from 9a01561 to 81e0713 Compare July 24, 2025 06:18
This prevents a test case from running
pento pushed a commit that referenced this pull request Jul 24, 2025
META tag processing can be simplified in most cases. Add an early check and return to avoid additional processing.

Developed in #9231.

Props jonsurrell, dmsnell.
See #63738.


git-svn-id: https://develop.svn.wordpress.org/trunk@60502 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jul 24, 2025
@sirreal
Copy link
Member Author

sirreal commented Jul 24, 2025

Merged in [60502].

@sirreal sirreal closed this Jul 24, 2025
@sirreal sirreal deleted the html-api/simplify-meta-tag-encoding-handling branch July 24, 2025 06:51
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Jul 24, 2025
META tag processing can be simplified in most cases. Add an early check and return to avoid additional processing.

Developed in WordPress/wordpress-develop#9231.

Props jonsurrell, dmsnell.
See #63738.

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


git-svn-id: https://core.svn.wordpress.org/trunk@59838 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Ninos pushed a commit to Ninos/wordpress-develop that referenced this pull request Jul 28, 2025
META tag processing can be simplified in most cases. Add an early check and return to avoid additional processing.

Developed in WordPress#9231.

Props jonsurrell, dmsnell.
See #63738.


git-svn-id: https://develop.svn.wordpress.org/trunk@60502 602fd350-edb4-49c9-b593-d223f7449a82
jonnynews pushed a commit to spacedmonkey/wordpress-develop that referenced this pull request Sep 24, 2025
META tag processing can be simplified in most cases. Add an early check and return to avoid additional processing.

Developed in WordPress#9231.

Props jonsurrell, dmsnell.
See #63738.


git-svn-id: https://develop.svn.wordpress.org/trunk@60502 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.

3 participants