Skip to content

fix: escape interpolated paths in generated virtual modules#164

Merged
uhyo merged 1 commit into
masterfrom
claude/issue-149-e4a6by
Jul 22, 2026
Merged

fix: escape interpolated paths in generated virtual modules#164
uhyo merged 1 commit into
masterfrom
claude/issue-149-e4a6by

Conversation

@uhyo

@uhyo uhyo commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #149.

The virtual:funstack/entries, client-init, and build-entry loaders in packages/static/src/plugin/index.ts spliced resolved paths into generated code as raw string literals. A path containing a " (or other characters needing escaping in a JS string literal) would produce a syntax error — or in the worst case, injected code — in the generated module.

All interpolated paths are now embedded with JSON.stringify(...), matching how the fsRoutes glob pattern was already handled:

  • Single-entry mode: Root and App imports
  • Multi-entry mode: the entries module re-export
  • fsRoutes mode: Root and adapter imports
  • virtual:funstack/client-init: the clientInit side-effect import
  • virtual:funstack/build-entry: the build entry re-export

Tests

Added unit tests in packages/static/src/plugin/index.test.ts that run configResolved with a Vite root containing a " character and assert each generated virtual module embeds the correctly escaped path.

pnpm test:run (107 tests), pnpm typecheck, pnpm lint, and pnpm format:check all pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_0136xqmAz4YqZVWnTPZgZdik


Generated by Claude Code

Wrap every path spliced into the virtual:funstack/entries, client-init,
and build-entry loaders with JSON.stringify, so paths containing quotes
or other characters needing escaping in a JS string literal no longer
produce syntax errors (or injected code) in the generated modules.

Closes #149

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0136xqmAz4YqZVWnTPZgZdik
@uhyo
uhyo merged commit a54c727 into master Jul 22, 2026
2 checks passed
@uhyo
uhyo deleted the claude/issue-149-e4a6by branch July 22, 2026 02:15
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.

Escape interpolated paths in generated virtual modules

2 participants