GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: do not pass user input to format string · nodejs/node@7b9adff

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_file.cc
  • test/es-module
    • test-cjs-legacyMainResolve.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_file.cc‎

Copy file name to clipboardExpand all lines: src/node_file.cc
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,10 +3079,11 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
30793079
return;
30803080
}
30813081

3082-
std::string err_module_message =
3083-
"Cannot find package '" + module_path + "' imported from " + module_base;
30843082
env->isolate()->ThrowException(
3085-
ERR_MODULE_NOT_FOUND(env->isolate(), err_module_message.c_str()));
3083+
ERR_MODULE_NOT_FOUND(env->isolate(),
3084+
"Cannot find package '%s' imported from %s",
3085+
module_path,
3086+
module_base));
30863087
}
30873088

30883089
void BindingData::MemoryInfo(MemoryTracker* tracker) const {
Collapse file

‎test/es-module/test-cjs-legacyMainResolve.js‎

Copy file name to clipboardExpand all lines: test/es-module/test-cjs-legacyMainResolve.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ describe('legacyMainResolve', () => {
133133
);
134134
});
135135

136+
it('should not crash when cannot resolve to a file that contains special chars', () => {
137+
const packageJsonUrl = pathToFileURL('/c/file%20with%20percents/package.json');
138+
assert.throws(
139+
() => legacyMainResolve(packageJsonUrl, { main: null }, packageJsonUrl),
140+
{ code: 'ERR_MODULE_NOT_FOUND' },
141+
);
142+
});
143+
136144
it('should throw when cannot resolve to a file (base not defined)', () => {
137145
const packageJsonUrl = pathToFileURL(
138146
path.resolve(

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.