Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error importing ES module with an encoded comma in the URL #40305

Closed
fasttime opened this issue Oct 4, 2021 · 2 comments
Closed

Error importing ES module with an encoded comma in the URL #40305

fasttime opened this issue Oct 4, 2021 · 2 comments
Labels
confirmed-bug Issues with confirmed bugs. esm Issues and PRs related to the ECMAScript Modules implementation.

Comments

@fasttime
Copy link
Contributor

fasttime commented Oct 4, 2021

Version

v16.10.0

Platform

No response

Subsystem

No response

What steps will reproduce the bug?

// test.mjs
import './foo%2cbar.mjs';

or

// test2.mjs
await import('./foo%2cbar.mjs');

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

Should import a module named "foo,bar.mjs" located in the same folder, if present, or throw an error with code ERR_MODULE_NOT_FOUND.

What do you see instead?

Throws:

TypeError [ERR_INVALID_MODULE_SPECIFIER]: Invalid module "./foo%2cbar.mjs" must not include encoded "/" or "\" characters imported from ./test.mjs

Note that there is no encoded "/" or "\" in "./foo%2cbar.mjs", just an encoded ","!

Additional information

In my understanding, this behavior results from a bug in lib/internal/modules/esm/resolve.js, where the regular expression encodedSepRegEx incorrectly matches an encoded slash or comma ("/" or ",") instead of a slash or backslash.

@targos
Copy link
Member

targos commented Oct 4, 2021

Thanks for the report @fasttime. Would you like to do a PR to fix it?

@targos targos added confirmed-bug Issues with confirmed bugs. esm Issues and PRs related to the ECMAScript Modules implementation. labels Oct 4, 2021
@fasttime
Copy link
Contributor Author

fasttime commented Oct 4, 2021

@targos Sure. Thanks for confirming.

aduh95 pushed a commit to aduh95/node that referenced this issue Oct 22, 2021
PR-URL: nodejs#40325
Fixes: nodejs#40305
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
aduh95 pushed a commit to aduh95/node that referenced this issue Oct 22, 2021
PR-URL: nodejs#40325
Fixes: nodejs#40305
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
targos pushed a commit that referenced this issue Oct 23, 2021
Fixes #40305

PR-URL: #40325
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
BethGriggs pushed a commit that referenced this issue Nov 23, 2021
Fixes #40305

PR-URL: #40325
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
richardlau pushed a commit that referenced this issue Nov 26, 2021
PR-URL: #40325
Backport-PR-URL: #40564
Fixes: #40305
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
richardlau pushed a commit that referenced this issue Nov 26, 2021
PR-URL: #40325
Backport-PR-URL: #40564
Fixes: #40305
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
richardlau pushed a commit that referenced this issue Dec 14, 2021
PR-URL: #40325
Backport-PR-URL: #40565
Fixes: #40305
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
abhishekumar-tyagi pushed a commit to abhishekumar-tyagi/node that referenced this issue May 5, 2024
PR-URL: nodejs/node#40325
Fixes: nodejs/node#40305
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. esm Issues and PRs related to the ECMAScript Modules implementation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants