Skip to content

fix: escaped double-quotes in helper string arguments (issue #584) - #621

Merged
rexm merged 2 commits into
masterfrom
worktree-agent-a51a71da285862ef7
Jun 20, 2026
Merged

fix: escaped double-quotes in helper string arguments (issue #584)#621
rexm merged 2 commits into
masterfrom
worktree-agent-a51a71da285862ef7

Conversation

@rexm

@rexmrexm commented Jun 20, 2026

Copy link
Copy Markdown
Member

Fixes#584

The expression lexer now correctly handles escaped double-quotes (\") inside double-quoted string arguments to helpers.

Root cause

LiteralParser.AccumulateLiteral had no escape-sequence handling. When parsing a delimited string literal like "hello \"world\"", it would stop at the first \" because " matched the delimiter check — ignoring the preceding backslash. This left the remaining world\" in the token stream, causing a null token and ultimately a NullReferenceException.

Fix

Added escape-sequence handling at the top of the accumulation loop in LiteralParser.cs. When a \ is seen inside a delimited literal:

  • If the next character is the closing delimiter, consume both and emit the raw delimiter character.
  • Otherwise, emit the backslash and continue (letting the next iteration handle the following character normally).

Tests

Two regression tests added to IssueTests.cs:

  • Issue584_EscapedDoubleQuoteInHelperStringArgument — verifies \" inside a double-quoted arg is treated as a literal "
  • Issue584_SingleQuoteStringArgStillWorks — ensures single-quoted string args are unaffected

All 1748 existing tests continue to pass.

rexmand others added 2 commits June 19, 2026 20:55
…ts (issue #584)
The LiteralParser's AccumulateLiteral method now correctly processes backslash
escape sequences inside delimited string literals, so that \" inside a
double-quoted helper argument is treated as a literal quote rather than
terminating the string. Adds two regression tests for issue #584.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rexm
rexm enabled auto-merge June 20, 2026 12:43
@sonarqubecloud

Copy link
Copy Markdown

@rexm
rexm merged commit 73698c0 into masterJun 20, 2026
7 checks passed
@rexm
rexm deleted the worktree-agent-a51a71da285862ef7 branch June 20, 2026 12:54
Sign up for freeto 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.

Using a custom helper in a escaped string, and escaping a string argument to that helper is not handled correctly by Handlebars.Net

1 participant

@rexm