Repository navigation
fix: escape string literals in generated output - #101
Merged
Merged
Conversation
Text and byte string values are now escaped before they are written between double quotes in Zod and TypeScript output. Valid escape sequences from the CDDL source are kept as-is. Raw double quotes, unpaired backslashes, control characters, and "*/" in doc comments are escaped.
mangeshraut712
left a comment
There was a problem hiding this comment.
Escaping at the single point where values are written between quotes is the right fix, and running the existing examples (including WebDriver BiDi) through unchanged is good evidence that nothing regressed. The unit tests cover the tricky interactions well, such as \\". One edge in the \u{...} acceptance check:
Accept any number of hex digits when the value is at most U+10FFFF.
sadym-chromium
approved these changes
Nov 10, 2026
OrKoN
added a commit
that referenced
this pull request
Nov 11, 2026
🤖 I have created a release *beep* *boop* --- ## [0.2.1](cddlconv-v0.2.0...cddlconv-v0.2.1) (2026-11-10) ### Bug Fixes * escape string literals in generated output ([#101](#101)) ([c9d1230](c9d1230)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Text and byte string values are now escaped before cddlconv writes them between double quotes in Zod and TypeScript output.
Changes
escape_js_string()insrc/util.rs:\",\\,\n,\u00e9,\u{...}, and others).'...') can contain them./after*, so values such assrc/**/*.tsstay valid in doc comments.it_works_with_string_literalssnapshot test for both engines.Example
Input:
Zod output before this change:
This output is not valid TypeScript. After this change:
Output for existing examples (including WebDriver BiDi) does not change.
Fixed: b/583870769