-
Notifications
You must be signed in to change notification settings - Fork 3.6k
HTML API: Update Processing Instruction handling #12424
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
sirreal
wants to merge
45
commits into
WordPress:trunk
Choose a base branch
from
sirreal:html-api/update-processing-instruction-parse
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
45 commits
Select commit
Hold shift + click to select a range
2482ea1
Tests: Update html5lib test data from WPT
sirreal 082b840
Tests: Rename HTML API external suite to WPT
sirreal f3c7b3e
Tests: Update WPT workflow group name
sirreal 5646973
Merge branch 'html-api-update-html5lib-wpt' into html-api/update-proc…
sirreal 81d528c
Remove PI test skips
sirreal f51e56d
Update and rename test structure
sirreal 0faa100
Update WPT dir
sirreal c2f47c8
Tag Processor: parse processing instructions per the HTML Standard
sirreal e3f60f6
HTML Processor: handle and serialize processing instruction tokens
sirreal 134041e
WPT harness: serialize processing instructions in tree dumps, skip br…
sirreal c4cd77d
HTML Processor: only rewrite IMAGE to IMG for tag tokens
sirreal d7e0898
Merge branch 'html-api-update-html5lib-wpt' into html-api/update-proc…
sirreal 5db5f4b
Update to latest version a315c382eac
sirreal c20858c
Merge branch 'trunk' into html-api-update-html5lib-wpt
sirreal f102e61
Add necessary PI skips
sirreal f134e89
Revert documentation change
sirreal 45e1452
Remove unused JS files
sirreal f5ad313
Merge branch 'html-api-update-html5lib-wpt' into html-api/update-proc…
sirreal aaf76c2
Simplify PI normalization comment
sirreal 0c7db12
Ensure PI data ending in `?` is serialized correctly
sirreal ca3d849
Update PI state docs
sirreal 4fa13c8
Use "processing instruction" state
sirreal d655770
Update PI example
sirreal 24eecae
Drop PI lookalike comments
sirreal d94eca0
Add phpstan-return to get_token_type
sirreal b87ea5b
Support set_modifiable_text on PI
sirreal 860a887
Add and improve test method types
sirreal cc427f0
Merge branch 'trunk' into html-api/update-processing-instruction-parse
sirreal 0721a4b
Update tree output for updated WPT
sirreal a66d0d4
Merge branch 'trunk' into html-api/update-processing-instruction-parse
sirreal 2c74364
Use 2-start comments for better ide formatting
sirreal cb61c12
Handle PI in build_visual_html_tree/assertEqualHTML
sirreal 754a7dc
Add visual tree tests
sirreal c344e29
Merge remote-tracking branch 'upstream/trunk' into html-api/update-pr…
sirreal 0fb5916
Use a single lexical update for PI modifiable text
sirreal 85111bd
Restore PI lookalike comment classification
sirreal 3a6e464
Always write the ?> closer for processing instructions
sirreal 4eee7ed
Remove stale claim about the spec PI serialization form
sirreal a2fbcb6
Clarify why PI support was added
sirreal b8eaaa3
Add/update PI bogus comment tests
sirreal 1f6e2b4
Add pi lookalike token test
sirreal 71724f2
Fix build_visual_html PI handling, improve test
sirreal 7b4bd4b
Update XML pi-lookalike comment
sirreal 692cbd1
Merge branch 'trunk' into html-api/update-processing-instruction-parse
sirreal 7bab900
Simplify serialize PI explanation.
sirreal 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1402,6 +1402,15 @@ public function serialize_token(): string { | |
| $html .= "<!--{$this->get_full_comment_text()}-->"; | ||
| break; | ||
|
|
||
| /** | ||
| * Processing instructions are serialized as `"<?" target " " data "?>"`. | ||
| * | ||
| * @see https://html.spec.whatwg.org/multipage/parsing.html#serialising-html-fragments | ||
| */ | ||
| case '#processing-instruction': | ||
| $html .= "<?{$this->get_tag()} {$this->get_modifiable_text()}?>"; | ||
| break; | ||
|
|
||
| case '#cdata-section': | ||
| $html .= "<![CDATA[{$this->get_modifiable_text()}]]>"; | ||
| break; | ||
|
|
@@ -1562,10 +1571,12 @@ private function step_initial(): bool { | |
|
|
||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->insert_html_element( $this->state->current_token ); | ||
| return true; | ||
|
|
||
|
|
@@ -1628,10 +1639,12 @@ private function step_before_html(): bool { | |
|
|
||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->insert_html_element( $this->state->current_token ); | ||
| return true; | ||
|
|
||
|
|
@@ -1733,10 +1746,12 @@ private function step_before_head(): bool { | |
|
|
||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->insert_html_element( $this->state->current_token ); | ||
| return true; | ||
|
|
||
|
|
@@ -1832,10 +1847,12 @@ private function step_in_head(): bool { | |
|
|
||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->insert_html_element( $this->state->current_token ); | ||
| return true; | ||
|
|
||
|
|
@@ -2158,10 +2175,12 @@ private function step_after_head(): bool { | |
|
|
||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->insert_html_element( $this->state->current_token ); | ||
| return true; | ||
|
|
||
|
|
@@ -2318,6 +2337,7 @@ private function step_in_body(): bool { | |
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->insert_html_element( $this->state->current_token ); | ||
| return true; | ||
|
|
||
|
|
@@ -3400,10 +3420,12 @@ private function step_in_table(): bool { | |
|
|
||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->insert_html_element( $this->state->current_token ); | ||
| return true; | ||
|
|
||
|
|
@@ -3721,10 +3743,12 @@ private function step_in_column_group(): bool { | |
|
|
||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->insert_html_element( $this->state->current_token ); | ||
| return true; | ||
|
|
||
|
|
@@ -4153,10 +4177,12 @@ private function step_in_select(): bool { | |
|
|
||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll assume this is the intention. This entire insertion mode is gone from the current version of the spec: #9298 |
||
| $this->insert_html_element( $this->state->current_token ); | ||
| return true; | ||
|
|
||
|
|
@@ -4378,12 +4404,14 @@ private function step_in_template(): bool { | |
| /* | ||
| * > A character token | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| * > A DOCTYPE token | ||
| */ | ||
| case '#text': | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| case 'html': | ||
| return $this->step_in_body(); | ||
|
|
||
|
|
@@ -4519,10 +4547,12 @@ private function step_after_body(): bool { | |
|
|
||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->bail( 'Content outside of BODY is unsupported.' ); | ||
| break; | ||
|
|
||
|
|
@@ -4612,10 +4642,12 @@ private function step_in_frameset(): bool { | |
|
|
||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->insert_html_element( $this->state->current_token ); | ||
| return true; | ||
|
|
||
|
|
@@ -4732,10 +4764,12 @@ private function step_after_frameset(): bool { | |
|
|
||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->insert_html_element( $this->state->current_token ); | ||
| return true; | ||
|
|
||
|
|
@@ -4802,10 +4836,12 @@ private function step_after_after_body(): bool { | |
| switch ( $op ) { | ||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->bail( 'Content outside of HTML is unsupported.' ); | ||
| break; | ||
|
|
||
|
|
@@ -4866,10 +4902,12 @@ private function step_after_after_frameset(): bool { | |
| switch ( $op ) { | ||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->bail( 'Content outside of HTML is unsupported.' ); | ||
| break; | ||
|
|
||
|
|
@@ -4989,10 +5027,12 @@ private function step_in_foreign_content(): bool { | |
|
|
||
| /* | ||
| * > A comment token | ||
| * > A processing instruction token | ||
| */ | ||
| case '#comment': | ||
| case '#funky-comment': | ||
| case '#presumptuous-tag': | ||
| case '#processing-instruction': | ||
| $this->insert_foreign_element( $this->state->current_token, false ); | ||
| return true; | ||
|
|
||
|
|
@@ -5306,8 +5346,12 @@ public function get_tag(): ?string { | |
| /* | ||
| * > A start tag whose tag name is "image" | ||
| * > Change the token's tag name to "img" and reprocess it. (Don't ask.) | ||
| * | ||
| * This only applies to tags; a processing instruction target or a | ||
| * comment which looks like a processing instruction may also report | ||
| * a tag name and must not be rewritten. | ||
| */ | ||
| return ( 'IMAGE' === $tag_name && 'html' === $this->get_namespace() ) | ||
| return ( 'IMAGE' === $tag_name && 'html' === $this->get_namespace() && '#tag' === $this->get_token_type() ) | ||
| ? 'IMG' | ||
| : $tag_name; | ||
| } | ||
|
|
@@ -5376,8 +5420,11 @@ public function get_token_name(): ?string { | |
| * - `#doctype` when matched on a DOCTYPE declaration. | ||
| * - `#presumptuous-tag` when matched on an empty tag closer. | ||
| * - `#funky-comment` when matched on a funky comment. | ||
| * - `#processing-instruction` when matched on a processing instruction. | ||
| * | ||
| * @since 6.6.0 Subclassed for the HTML Processor. | ||
| * @since 7.1.0 Recognize processing instructions according to an HTML | ||
| * specification update. | ||
| * | ||
| * @return string|null What kind of token is matched, or null. | ||
| */ | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
whatwg/html#12654