fix(node-api): decode percent-encoded path before process.dlopen#49
Open
NathanWalker wants to merge 1 commit into
Open
fix(node-api): decode percent-encoded path before process.dlopen#49NathanWalker wants to merge 1 commit into
NathanWalker wants to merge 1 commit into
Conversation
`URL.pathname` is percent-encoded, but `process.dlopen` expects a filesystem
path. Any space in the package's path therefore reaches dlopen as "%20" and the
addon fails to load:
TypeError: dlopen(/Applications/My%20App.app/.../NativeScript, 0x0001):
tried: '.../My%20App.app/...' (no such file)
This breaks every packaged app whose path contains a space — for example an
.app installed to /Applications with a display name like "My App.app". It goes
unnoticed in development because the package normally resolves from a
node_modules path with no spaces, where decoding is a no-op; only a distributed
bundle exercises the failing path.
Wrap the resolved pathname in decodeURIComponent() at all three dlopen sites:
- packages/macos-node-api/index.mjs
- packages/macos-node-api/index.cjs
- packages/ios-node-api/index.js
Verified on macOS by copying packages/macos-node-api together with its built
NativeScript.framework into a directory whose name contains a space, then
importing it under Deno:
- before: dlopen fails with the %20 path shown above
- after: the addon loads and init() runs
Note: paths containing "#" or "?" are still mishandled, because the base URL is
built by string concatenation and those characters are parsed as fragment/query
delimiters. Spaces are by far the common case; a complete fix would resolve the
addon path without going through URL at all.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
URL.pathnameis percent-encoded, butprocess.dlopenexpects a filesystem path. Any space in the package's path therefore reaches dlopen as "%20" and the addon fails to load:This breaks every packaged app whose path contains a space — for example an .app installed to /Applications with a display name like "My App.app". It goes unnoticed in development because the package normally resolves from a node_modules path with no spaces, where decoding is a no-op; only a distributed bundle exercises the failing path.
Wrap the resolved pathname in decodeURIComponent() at all three dlopen sites:
Verified on macOS by copying packages/macos-node-api together with its built NativeScript.framework into a directory whose name contains a space, then importing it under Deno:
Note: paths containing "#" or "?" are still mishandled, because the base URL is built by string concatenation and those characters are parsed as fragment/query delimiters. Spaces are by far the common case; a complete fix would resolve the addon path without going through URL at all.