Skip to content

Commit 603db00

Browse files
committed
Feedback response
1 parent 713e230 commit 603db00

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/wp-includes/html-api/class-wp-html-tag-processor.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
* - Prune the whitespace when removing classes/attributes: e.g. "a b c" -> "c" not " c".
1616
* This would increase the size of the changes for some operations but leave more
1717
* natural-looking output HTML.
18-
* - Decode HTML character references within class names when matching. E.g. match having
19-
* class `1<"2` needs to recognize `class="1&lt;&quot;2"`. Currently the Tag Processor
20-
* will fail to find the right tag if the class name is encoded as such.
2118
* - Properly decode HTML character references in `get_attribute()`. PHP's
2219
* `html_entity_decode()` is wrong in a couple ways: it doesn't account for the
2320
* no-ambiguous-ampersand rule, and it improperly handles the way semicolons may
@@ -375,14 +372,14 @@ class WP_HTML_Tag_Processor {
375372
*
376373
* @since {WP_VERSION}
377374
*
378-
* @see WP_HTML_Tag_Processor::STATE_UNKNOWN
375+
* @see WP_HTML_Tag_Processor::STATE_READY
379376
* @see WP_HTML_Tag_Processor::STATE_COMPLETE
380377
* @see WP_HTML_Tag_Processor::STATE_INCOMPLETE
381378
* @see WP_HTML_Tag_Processor::STATE_MATCHED_TAG
382379
*
383380
* @var string
384381
*/
385-
private $parser_state = self::STATE_UNKNOWN;
382+
private $parser_state = self::STATE_READY;
386383

387384
/**
388385
* How many bytes from the original HTML document have been read and parsed.
@@ -663,7 +660,7 @@ public function next_token() {
663660
* The next step in the parsing loop determines the parsing state;
664661
* clear it so that state doesn't linger from the previous step.
665662
*/
666-
$this->parser_state = self::STATE_UNKNOWN;
663+
$this->parser_state = self::STATE_READY;
667664

668665
if ( $this->bytes_already_parsed >= strlen( $this->html ) ) {
669666
$this->parser_state = self::STATE_COMPLETE;
@@ -721,7 +718,8 @@ public function next_token() {
721718
's' === $t || 'S' === $t ||
722719
't' === $t || 'T' === $t ||
723720
'x' === $t || 'X' === $t
724-
) ) {
721+
)
722+
) {
725723
$tag_name = $this->get_tag();
726724

727725
if ( 'SCRIPT' === $tag_name && ! $this->skip_script_data() ) {
@@ -2647,7 +2645,7 @@ private function matches() {
26472645
return true;
26482646
}
26492647

2650-
const STATE_UNKNOWN = 'UNKNOWN: The parser is waiting for a state transition; it may not have started, or it may have been interrupted, or it may be waiting to restart after pausing.';
2648+
const STATE_READY = 'READY: The parser is waiting for a state transition; it may not have started, or it may have been interrupted, or it may be waiting to restart after pausing.';
26512649
const STATE_COMPLETE = 'COMPLETE: The parser has reached the end of the document without truncating any possible tokens. There is nothing left to scan.';
26522650
const STATE_INCOMPLETE = 'INCOMPLETE: The parser has reached the end of the document but it appears as thought the HTML is truncated inside a token. It has backed up to the last-known complete state and will not continue parsing.';
26532651
const STATE_MATCHED_TAG = 'MATCHED_TAG: The parser has found a tag and paused to allow reading from and modifying its attributes.';

0 commit comments

Comments
 (0)