Skip to content

Comments

fix: escape string literals in GenerateIds.ts code generation#91

Open
AugustHagedal wants to merge 1 commit intoSnapchat:mainfrom
AugustHagedal:new-branch
Open

fix: escape string literals in GenerateIds.ts code generation#91
AugustHagedal wants to merge 1 commit intoSnapchat:mainfrom
AugustHagedal:new-branch

Conversation

@AugustHagedal
Copy link

@AugustHagedal AugustHagedal commented Feb 21, 2026

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, \t for ObjC @"..." string literals (line 120)
  • escapeJSSingleQuotedString — escapes \, ', \n, \r, \t for JS '...' string literals (line 153)

StringEscape.ts (toCString) was intentionally not reused — it targets C code with different delimiter conventions.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Testing

  • Tests pass locally (npm run test in compiler/companion)
  • Added/updated tests for changes (if applicable)
  • Tested on multiple platforms (iOS/Android/Web/macOS as applicable)
  • Manual testing performed (describe below)

Testing Details

Added 4 regression tests in GenerateIds.spec.ts covering double-quote and backslash escaping for both ObjC and JS output (9 tests total, all passing). The pre-existing SQLiteCompilationCache test failure is a pre-existing environment issue (native binary compiled against a different Node.js version) and is unrelated to this change.

Checklist

  • Code follows project style guidelines
  • Documentation updated (if needed)
  • No breaking changes (or documented in description)
  • Commit messages follow conventional format
  • No secrets, API keys, or internal URLs included

Related Issues

Additional Context

Prettier (npm run format) was run as part of validation and produced no changes to the modified files.

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