Skip to content

fix(lexer): in an escaped string, } closes a block and a code-point escape is one character - #614

Open
Rush wants to merge 1 commit into
voidzero-dev:mainfrom
encharm:fix/lexer-escaped-block-close
Open

Rush wants to merge 1 commit into
voidzero-dev:mainfrom
encharm:fix/lexer-escaped-block-close

Conversation

@Rush

@Rush Rush commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

In escaped-string mode (with_escaped_string, how ngtsc lexes an inline template in place, as the raw text of its string literal), the lexer never turned } into BLOCK_CLOSE, so a block never closed:

<div>@if (a) {<b></b>}</div>

lexed with escaped strings gave an unclosed @if and an unexpected closing </div>.

The exception was there because the escaped cursor read \u{01} as separate characters, and the } that ends that escape would otherwise close a block. This makes the cursor read a code-point escape (\u{X...}, \uXXXX, \xXX, octal) as the one character it stands for, as Angular's EscapedCharacterCursor does, and drops the exception. An escape for NUL is left to process_escape_sequences, which ends the text there, as Angular's cursor ends input at $EOF.

test_block_close_in_escaped_string covers a block, a block inside an element, and an escaped } (\u{7d}, which closes a block in Angular too). The conformance suite passes 1264/1264 with its snapshot unchanged, including the variable-length Unicode cases that read \u{...} escapes.

… escape is one character

In escaped-string mode (how ngtsc lexes an inline template in place) the lexer never made `}` a BLOCK_CLOSE, so a
block never closed. The exception existed because the cursor read `\\u{01}` as separate characters, whose `}` would
otherwise close a block. The cursor now reads a code-point escape (`\\u{X...}`, `\\uXXXX`, `\\xXX`, octal) as the
one character it stands for, as Angular's EscapedCharacterCursor does, and the exception is gone. An escape for NUL
is left to process_escape_sequences, which ends the text there, as Angular's cursor ends input at $EOF.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant