Skip to content

📙📇: preserve strings in generated source expressions - #1845

Open
merryman wants to merge 3 commits into
mainfrom
robin/generated-string-escaping
Open

merryman wants to merge 3 commits into
mainfrom
robin/generated-string-escaping

Conversation

@merryman

@merryman merryman commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Generated JavaScript could change string contents through incomplete or repeated escaping. The shared string printer now preserves backslashes, quotes, carriage returns, newlines, and Unicode line and paragraph separators, including strings nested in arrays. Multiline values print escaped newline characters rather than JavaScript line continuations, so evaluating the generated expression retains the original line breaks.

Rich-text serialization delegates escaping to the shared printer exactly once. Committed printer and serializer regressions cover string round-trips and formatted labels with LF, CRLF, and a backslash followed by a newline.

Refs #1149. This preserves generated expression contents; the remaining structural reconciliation work stays open.

Escape backslashes in the object inspector's string printer before quotes
and newlines. Serialize raw text-and-attribute elements without a separate
pre-escaping pass, so generated expressions escape text exactly once.
Add an object-inspection round-trip regression.
Escape carriage returns and Unicode line and paragraph separators in the
object inspector. Reuse that printer for string.print so backslashes and
line terminators are escaped consistently, retaining array recursion and
non-string output. Add literal round-trip and label-expression regressions.
Exercise serializeSpec and deserializeExprObj with LF, CRLF and a backslash before a newline. The cases reject the former newline pre-escape as well as the pre-S3 string printer.
@merryman
merryman force-pushed the robin/generated-string-escaping branch from b6cf156 to 605da60 Compare November 5, 2026 10:46

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.

1 participant