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 — url: process crash via malformed UNC hostname in pathToFileURL() · nodejs/node@9a25fc8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_url.cc
  • test/parallel
    • test-url-pathtofileurl.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_url.cc‎

Copy file name to clipboardExpand all lines: src/node_url.cc
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ constexpr auto lookup_table = []() consteval {
9393
case CHAR: \
9494
result[i] = {{'%', HEX_DIGIT_2, HEX_DIGIT_1, 0}}; \
9595
break;
96-
9796
ENCODE_CHAR('\0', '0', '0') // '\0' == 0x00
9897
ENCODE_CHAR('\t', '0', '9') // '\t' == 0x09
9998
ENCODE_CHAR('\n', '0', 'A') // '\n' == 0x0A
@@ -169,7 +168,11 @@ void BindingData::PathToFileURL(const FunctionCallbackInfo<Value>& args) {
169168
[[unlikely]] {
170169
CHECK(args[2]->IsString());
171170
Utf8Value hostname(isolate, args[2]);
172-
CHECK(out->set_hostname(hostname.ToStringView()));
171+
if (!out->set_hostname(hostname.ToStringView())) {
172+
return ThrowInvalidURL(realm->env(),
173+
input.ToStringView(),
174+
std::string(hostname.ToStringView()));
175+
}
173176
}
174177

175178
binding_data->UpdateComponents(out->get_components(), out->type);
Collapse file

‎test/parallel/test-url-pathtofileurl.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-url-pathtofileurl.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ const url = require('url');
2121
assert.ok(fileURL.includes('%25'));
2222
}
2323

24+
{
25+
assert.throws(() => {
26+
url.pathToFileURL('\\\\exa mple\\share\\file.txt', { windows: true });
27+
}, {
28+
code: 'ERR_INVALID_URL',
29+
});
30+
}
31+
2432
{
2533
if (isWindows) {
2634
// UNC path: \\server\share\resource

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.