fix: escape string literals in GenerateIds.ts code generation#91
Open
AugustHagedal wants to merge 1 commit intoSnapchat:mainfrom
Open
fix: escape string literals in GenerateIds.ts code generation#91AugustHagedal wants to merge 1 commit intoSnapchat:mainfrom
AugustHagedal wants to merge 1 commit intoSnapchat:mainfrom
Conversation
Module names containing double-quotes, single-quotes, or backslashes were embedded into generated ObjC and TypeScript/JS code without escaping, producing syntactically broken output. Add escapeObjCString and escapeJSSingleQuotedString helpers and apply them at the two affected sites. Adds four regression tests covering both characters for both output languages.
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.
Description
Module names containing
",', or\were embedded directly into generated Objective-C and TypeScript/JS code without escaping, producing syntactically broken output — the same class of bug as the recently fixed IR escaping issue.Two helper functions are added and applied at the two affected sites:
escapeObjCString— escapes\,",\n,\r,\tfor ObjC@"..."string literals (line 120)escapeJSSingleQuotedString— escapes\,',\n,\r,\tfor JS'...'string literals (line 153)StringEscape.ts(toCString) was intentionally not reused — it targets C code with different delimiter conventions.Type of Change
Testing
npm run testincompiler/companion)Testing Details
Added 4 regression tests in
GenerateIds.spec.tscovering double-quote and backslash escaping for both ObjC and JS output (9 tests total, all passing). The pre-existingSQLiteCompilationCachetest failure is a pre-existing environment issue (native binary compiled against a different Node.js version) and is unrelated to this change.Checklist
Related Issues
Additional Context
Prettier (
npm run format) was run as part of validation and produced no changes to the modified files.