Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 76ba129

Browse filesBrowse files
Stewart Addisonaddaleax
authored andcommitted
net: allow wider regex in interface name
Zone IDs on Linux are network interface names. The regex we use to determine valid IPs does not allow for non-alphanumeric characters in the zone ID suffix. Some machines (including the RHEL Linux/s390x machines from Marist) have zone IDs with a '.' character in them which the regex in net.isIP rejects. This changes the regex. Ref: #14500 Signed-off-by: Stewart Addison <sxa@uk.ibm.com> PR-URL: #34364 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 2ab3fcc commit 76ba129
Copy full SHA for 76ba129

File tree

Expand file treeCollapse file tree

2 files changed

+4
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/net.js‎

Copy file name to clipboardExpand all lines: lib/internal/net.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const IPv6Reg = new RegExp('^(' +
2525
`(?:${v6Seg}:){2}(?:(:${v6Seg}){0,3}:${v4Str}|(:${v6Seg}){1,5}|:)|` +
2626
`(?:${v6Seg}:){1}(?:(:${v6Seg}){0,4}:${v4Str}|(:${v6Seg}){1,6}|:)|` +
2727
`(?::((?::${v6Seg}){0,5}:${v4Str}|(?::${v6Seg}){1,7}|:))` +
28-
')(%[0-9a-zA-Z]{1,})?$');
28+
')(%[0-9a-zA-Z-.:]{1,})?$');
2929

3030
function isIPv4(s) {
3131
return IPv4Reg.test(s);
Collapse file

‎test/parallel/test-net-isip.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-net-isip.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ assert.strictEqual(net.isIP('::2001:252:1:2008:6'), 6);
4646
assert.strictEqual(net.isIP('::2001:252:1:1.1.1.1'), 6);
4747
assert.strictEqual(net.isIP('::2001:252:1:255.255.255.255'), 6);
4848
assert.strictEqual(net.isIP('::2001:252:1:255.255.255.255.76'), 0);
49+
assert.strictEqual(net.isIP('fe80::2008%eth0'), 6);
50+
assert.strictEqual(net.isIP('fe80::2008%eth0.0'), 6);
51+
assert.strictEqual(net.isIP('fe80::2008%eth0@1'), 0);
4952
assert.strictEqual(net.isIP('::anything'), 0);
5053
assert.strictEqual(net.isIP('::1'), 6);
5154
assert.strictEqual(net.isIP('::'), 6);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.