Skip to content

fix(recipe): unescape escaped quotes and backslashes in quoted values - #396

Open
rahul05ranjan wants to merge 1 commit into
hypit-ai:mainfrom
rahul05ranjan:fix/svs-unescape-quoted-values
Open

rahul05ranjan wants to merge 1 commit into
hypit-ai:mainfrom
rahul05ranjan:fix/svs-unescape-quoted-values

Conversation

@rahul05ranjan

Copy link
Copy Markdown

Quoted SVS Recipe values that escape an inner quote kept the backslashes in the parsed value, so text: "He said \"hi\" twice"; came out as the literal He said \"hi\" twice and any prompt/caption text built from the Recipe showed the stray backslashes end to end.

The boundary scanners (withoutComments, closingBrace, closingSheet, valueSemicolon) all already treat a backslash inside quotes as an escape — that is what lets an escaped quote, ; or } sit inside a quoted value while the scanner still finds the right terminators — but parseValue only stripped the outer quote pair and returned the raw inner text, so the escape form was accepted structurally and shipped through verbatim.

This unescapes the escaped delimiter quote and the escaped backslash in parseValue when producing the value for a quoted token, so the value layer finally agrees with the scanners. Scanner behavior is unchanged, and no new escape forms are introduced.

Test: packages/recipe/test/source-closure.test.ts pins the issue example plus the escaped-backslash and single-quoted variants; it fails on unfixed main (He said \"hi\" twice) and passes with this change.

Fixes #392

The SVS boundary scanners (withoutComments, closingBrace, closingSheet,
valueSemicolon) all treat a backslash inside quotes as an escape, but
parseValue only stripped the outer quote pair and returned the raw inner
text, so \" sequences shipped through verbatim. Unescape the escaped
delimiter quote and the escaped backslash when producing the value,
matching what the scanners already accept.

Fixes hypit-ai#392

Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

SVS: escaped quotes in quoted Recipe values are honored by the boundary scanners but never unescaped, so \" leaks into the value

1 participant