You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b4c3707
Browse filesBrowse the repository at this point in the historyBrowse files
fix(css): resolve an escape the input ran out of (#22257)
* fix(css): resolve an escape the input ran out of
A `\` no character follows is an escape CSS Syntax 3 resolves: to the
replacement character anywhere but inside a string (§4.3.7), and to
nothing inside one (§4.3.5). `A.source` already read it that way, but the
two accessors beside it — `name` and `unescaped`, in both the path and
the materialized-node implementations — handed back the `\` as written.
Printing it is what made this visible. `_rulePrelude` reads an at-rule's
name through `name`, and a blockless at-rule is closed with `;`, so
`@\30 media\` printed as `@\30 media\;` — where the `\` escapes the `;`
rather than ending the statement. A second pass then read one statement
where the first wrote one and added another `;`, so the output grew a
byte per pass instead of standing still. The fixture added here is what
`yarn test:invariants:css` now holds that to; it reports `idempotence —
differs, +1 B` under all three presets without this change.
A string's `\` carries one more meaning the identifier unescape has no
context for: before a newline it is a line continuation, naming nothing.
It has to be read in the same pass as the escapes around it rather than
stripped ahead of them — removing `\`+newline from `"\41\<newline>b"`
first leaves `\41b`, which then spells U+041B instead of `A` and `b`.
`rule_list` was the corpus's own answer rather than webpack's: it states
"parse a list of rules" with the top-level flag unset, which is
`parseABlocksContents`, while the suite ran it through
`parseAStylesheetsContents` — the flag set, where CDO/CDC are discarded
between rules. webpack implemented both correctly; only the mapping was
wrong. All 11 of that file's cases now agree.
The five entries this retires from `KNOWN_DIVERGENCES` were asserted to
*still* diverge, so the suite failed on them before the list was updated.
* chore(changeset): keep the escape entry within the length limit
The unioned entry ran to 85 characters, over the 80 the guide sets. It
names the same two things in fewer words rather than dropping the
at-rule-name half the entry already carried.
* test(css): cover the escape meanings a stylesheet cannot reach
Four of the branches the fix added were reached by nothing: a string whose
escape the input ran out of, a closing quote an odd run of backslashes
escaped, a `\\` inside a string, and a CR or CRLF line continuation. Each
needs the source to stop mid-escape or to spell a newline the corpus does
not, so a `configCases/` stylesheet cannot drive them — a build appends a
newline after a module's content, which makes the last `\` a delim token
rather than an escape at end of input.
Counted rather than assumed: instrumenting each branch and replaying the
committed corpus cases plus the invariants fixture reached six of ten, and
the same count reaches all ten with these. Both halves are checked by
mutation — removing the CR arm fails one case, and resolving a string's
trailing escape to the replacement character fails three.
0 commit comments