Commit cc96ed2
committed
HTML API: Avoid processing incomplete syntax elements.
The HTML Tag Processor is able to know if it starts parsing a syntax element
and reaches the end of the document before it reaches the end of the element.
In these cases, after this patch, the processor will indicate this condition.
For example, when processing `<div><input type="te` there is an incomplete INPUT
element. The processor will fail to find the INPUT, it will pause right after
the DIV, and `paused_at_incomplete_token()` will return `true`.
This patch doesn't change any existing behaviors, but it adds the new method
to report on the final failure condition. It provides a mechanism for later
use to add chunked parsing to the class, wherein it will be possible to process
a document without having the entire document loaded in memory, for example
when processing unbuffered output.
This is also a necessary change for adding the ability to scan every token in
the document. Currently the Tag Processor only exposes tags as tokens, but it
will need to process `#text` nodes, HTML comments, and other markup in order
to enable behaviors in the HTML Processor and in refactors of existing HTML
processing in Core.1 parent 7aa146d commit cc96ed2
File tree
3 files changed
+530
-88
lines changed- src/wp-includes/html-api
- tests/phpunit/tests/html-api
3 files changed
+530
-88
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | 148 | | |
160 | 149 | | |
161 | 150 | | |
| |||
516 | 505 | | |
517 | 506 | | |
518 | 507 | | |
519 | | - | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
520 | 511 | | |
521 | 512 | | |
522 | 513 | | |
| |||
0 commit comments