fix(md-copy): leading semicolon on the injected payload (ASI safety)#7
Closed
phase3dev wants to merge 1 commit into
Closed
fix(md-copy): leading semicolon on the injected payload (ASI safety)#7phase3dev wants to merge 1 commit into
phase3dev wants to merge 1 commit into
Conversation
When appended after a bundle whose final statement is an expression with no trailing semicolon, the IIFE would parse as a call on that expression and throw before the webview app initializes. Prefix the payload with ';' so the patch is safe regardless of the bundle's final token. Regenerated the three embeds; adds a node-exec test on a no-semicolon bundle. Not triggered by the current 2.1.170 bundle (it ends with '}'); this hardens against future builds. Codex PR review, P2. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
Superseded by #8. The leading- |
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.
Summary
Addresses the Codex PR-review note on #6 (P2): prefix the injected webview payload with a leading
;.When the self-contained IIFE is appended to
webview/index.jsafter a bundle whose final statement is an expression with no trailing semicolon, JavaScript would parse it as a call on that expression (lastExpr(function(){...})()) and throw before the webview app initializes. The leading;makes the patch safe regardless of the bundle's final token. This matches the design's "robust across builds" intent.Not triggered by the current 2.1.170 bundle (it ends with
}); this is forward-hardening.Regenerated the three embeds (bash / node / python) from the updated source.
Test plan
tests/test_md_patcher.py)python3 -m unittest discover -s tests(86 cases)python3 tools/gen-embeds --check --strict·bash -n/ ShellCheck /node --check🤖 Generated with Claude Code