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
Reject malformed/out-of-range \u and \x escapes in untagged templates
Templates tokenize via the engine's scanTemplateSpan, not the token regex, so the
string-side fix (token regex) doesn't reach them. Add an opt-in token option
escapeValid: the lexer validates each \-escape in a template against it and
throws on a malformed one.
Crucially this is gated on tag position: a TAGGED template legally carries invalid
escapes (cooked = undefined, since ES2018), e.g. String.raw`\u{110000}`, which TS
accepts — only an *untagged* literal rejects them. "Is this template tagged?" is the
same "is the previous token a value?" question the lexer already answers for
regex-vs-division, so that predicate is factored into prevIsValue() and shared.
Interpolation middle/tail spans skip validation (tagged-ness isn't re-derivable
there) — conservative, no regression.
Rejects untagged `\u{110000}`, `\u{r}`, `\u{}`; still accepts tag`\u{110000}`.
FP 108->103 (5 unicodeExtendedEscapesInTemplates cases), FN stays 0 (3376/3376),
TP unchanged. Engine stays language-agnostic (agnostic 5/5, refactor-guard 112/112,
highlighter 99.3% unchanged); the \u/\x rule lives entirely in examples/typescript.ts.
0 commit comments