-
Notifications
You must be signed in to change notification settings - Fork 215
Make: drop o2's control classes from comment HTML #879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bor0
wants to merge
2
commits into
WordPress:trunk
Choose a base branch
from
bor0:make/strip-o2-control-classes-from-comments
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: WordPress/wordpress.org
Length of output: 24124
🏁 Script executed:
Repository: WordPress/wordpress.org
Length of output: 3509
🏁 Script executed:
Repository: WordPress/wordpress.org
Length of output: 27644
🏁 Script executed:
Repository: WordPress/wordpress.org
Length of output: 2162
🌐 Web query:
site:developer.wordpress.org WP_HTML_Tag_Processor class_list character references wp_kses_normalize_entities💡 Result:
In WordPress, the WP_HTML_Tag_Processor class and the wp_kses_normalize_entities function serve distinct purposes related to HTML processing, and they handle character references differently [1][2][3]. WP_HTML_Tag_Processor::class_list The class_list method is a generator that iterates over the class names found in a matched tag's class attribute [1][2]. When retrieving the class attribute using $this->get_attribute('class'), the WP_HTML_Tag_Processor automatically handles the decoding of character references within that attribute value [1][2]. The resulting string, used by class_list to parse individual class names, contains these character references already decoded [1][2]. wp_kses_normalize_entities This function is a legacy utility within the KSES sanitization library designed to normalize HTML entities within a string [3][4]. It is typically used to sanitize content by: - Disarming entities (converting & to &) [3]. - Decoding double-encoded character references [3]. - Ensuring named entities are valid or correctly formatted based on the context (e.g., 'html' or 'xml') [3][5]. Relationship and Distinction There is no direct functional dependency between WP_HTML_Tag_Processor::class_list and wp_kses_normalize_entities [1][3]. - WP_HTML_Tag_Processor is a modern, high-performance HTML parser that handles character decoding internally according to HTML5 specifications during tokenization and attribute access [6][2]. - wp_kses_normalize_entities is an older utility function used primarily for manual string sanitization before or during content filtering, rather than as part of the HTML5-compliant parsing flow used by the Tag Processor [3][7][8]. Developers should use the WP_HTML_Tag_Processor API for manipulating HTML tags and attributes as it correctly handles character references per the HTML5 spec, whereas wp_kses_normalize_entities should be reserved for scenarios requiring manual normalization of raw text strings [2][3].
Citations:
🌐 Web query:
site:github.com/WordPress/wordpress-develop wp_kses_normalize_entities numeric character reference 45 source💡 Result:
In the context of the WordPress function wp_kses_normalize_entities, there is no special or unique behavior associated specifically with the numeric character reference 45 (which represents the hyphen character,
-). The function wp_kses_normalize_entities is designed to normalize HTML entities by standardizing their representation within a string [1]. It handles numeric character references (both decimal and hexadecimal) using regular expression callbacks (such as wp_kses_normalize_entities2 for decimal) to ensure they contain valid Unicode values [2][1]. The value 45 is a standard, valid Unicode codepoint for a hyphen. When processed by the function: 1. It is treated as a standard numeric character reference (e.g., - or -). 2. The regex and callback logic in WordPress verify the validity of the numeric value [2][1]. 3. If valid, the function ensures the entity remains correctly encoded or is normalized according to the function's internal logic [1]. Recent updates to the WordPress core have focused on improving how these entities are handled to prevent "mangling"—for example, ensuring that double-encoded entities like ' are not incorrectly transformed [3]. Testing suites for this function specifically include various numeric and hex character references to ensure that symbols, standard characters, and emojis are processed accurately without changing their semantic meaning [4]. If you encountered a reference to 45 in source code, it is likely part of a test case or a range check ensuring that the function correctly processes standard ASCII or Unicode numeric references [4].Citations:
🏁 Script executed:
Repository: WordPress/wordpress.org
Length of output: 5358
Do not skip encoded
o2-control classes.wp_kses_normalize_entities()preserves valid numeric references and normalizes-to-. Therefore,strip_o2_control_classes()does not findo2-inclass="o2-reply"and returns beforeWP_HTML_Tag_Processor::class_list()decodes the class. Remove the fast path and always inspect parsed class names.🤖 Prompt for AI Agents