Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#61831 closed defect (bug) (fixed)

HTML API: Unclosed "funky comment" may not pause at incomplete token

Reported by: jonsurrell Owned by: jonsurrell
Priority: normal Milestone: 6.7
Component: HTML API Version: 6.5
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

The HTML Tag Processor may report ::paused_at_incomplete_token() === true correctly when the HTML ends in an open "funky comment."

The HTML </# should be handled the same as </# , in both cases a funky comment has been opened but no closer is found before the HTML document ends. Both cases should both be treated as incomplete input, however the former case (with no trailing space) does not report an incomplete token.

Change History (8)

#1 @jonsurrell
2 years ago

I've confirmed this in 6.5, but the behavior may have existed earlier.

This ticket was mentioned in ​PR #7146 on ​WordPress/wordpress-develop by ​@jonsurrell.


2 years ago
#2

  • Keywords has-patch has-unit-tests added
  • Fix an issue where </# is not treated as incomplete input but </# is. Both should be incomplete input.
  • Add a test for the issue.

---

The HTML Tag Processor may report ::paused_at_incomplete_token() === true correctly when the HTML ends in an open "funky comment."

The HTML </# should be handled the same as </# , in both cases a funky comment has been opened but no closer is found before the HTML document ends. Both cases should both be treated as incomplete input, however the former case (with no trailing space) does not report an incomplete token.

Trac ticket: https://core.trac.wordpress.org/ticket/61831

#3 @jonsurrell
2 years ago

This was discovered by the HTML5lib-tests full HTML API parser tests, in progress in ​https://github.com/WordPress/wordpress-develop/pull/7117.

Last edited 2 years ago by jonsurrell (previous) (diff)

This ticket was mentioned in ​PR #7117 on ​WordPress/wordpress-develop by ​@jonsurrell.


2 years ago
#4

Trac ticket: Core-61646

Previously, the html5lib tests have only run in the fragment parser mode, but in #6977 a full parser was introduced to the HTML API. In this patch, the html5lib tests are running in the full parser mode where applicable.

#7146 is merged here and should be landed first.

- Tests: 609, Assertions: 405, Skipped: 204.
+ Tests: 1498, Assertions: 787, Skipped: 711.

This vastly increases the tests that are used from HTML5lib-tests from 609 to 1498! It's helped to discover two issues:

#5 @dmsnell
2 years ago

  • Resolution → fixed
  • Status assigned → closed

In 58858:

HTML API: Truncated funky comments should cause the Tag Processor to pause.

A state change was missing in the Tag Processor when the input is too short to
find a comment closer after an opened funky comment. This patch fixes a issue
where </# does not correctly report incomplete input, but </# does.

Developed in ​https://github.com/wordpress/wordpress-develop/pull/7146
Discussed in https://core.trac.wordpress.org/ticket/61831

Props: jonsurrell.
Fixes #61831.

#7 @sabernhardt
2 years ago

  • Milestone Awaiting Review → 6.7
Note: See TracTickets for help on using tickets.