Skip to content

Commit ccb5f07

Browse files
jakecastellilouwers
authored andcommitted
Revert "net: validate host name for server listen"
This reverts commit 52322aa. PR-URL: nodejs#54554 Reviewed-By: Claudio Wunder <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ulises Gascón <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 6f1ad28 commit ccb5f07

File tree

2 files changed

+0
-20
lines changed

2 files changed

+0
-20
lines changed

lib/net.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ const {
3535
NumberParseInt,
3636
ObjectDefineProperty,
3737
ObjectSetPrototypeOf,
38-
RegExp,
39-
RegExpPrototypeExec,
4038
Symbol,
4139
SymbolAsyncDispose,
4240
SymbolDispose,
@@ -145,8 +143,6 @@ const { kTimeout } = require('internal/timers');
145143
const DEFAULT_IPV4_ADDR = '0.0.0.0';
146144
const DEFAULT_IPV6_ADDR = '::';
147145

148-
const HOST_REGEXP = new RegExp('^[a-zA-Z0-9-:%.]+$');
149-
150146
const noop = () => {};
151147

152148
const kPerfHooksNetConnectContext = Symbol('kPerfHooksNetConnectContext');
@@ -2024,10 +2020,6 @@ Server.prototype.listen = function(...args) {
20242020
toNumber(args.length > 2 && args[2]); // (port, host, backlog)
20252021

20262022
options = options._handle || options.handle || options;
2027-
if (typeof options.host === 'string' && RegExpPrototypeExec(HOST_REGEXP, options.host) === null) {
2028-
throw new ERR_INVALID_ARG_VALUE('host', options.host);
2029-
}
2030-
20312023
const flags = getFlags(options.ipv6Only);
20322024
// Refresh the id to make the previous call invalid
20332025
this._listeningId++;

test/parallel/test-net-server-listen-options.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ function close() { this.close(); }
1515
// Test listen({port})
1616
net.createServer().listen({ port: 0 })
1717
.on('listening', common.mustCall(close));
18-
// Test listen(host, port}) on ipv4
19-
net.createServer().listen({ host: '127.0.0.1', port: '3000' }).on('listening', common.mustCall(close));
20-
// Test listen(host, port}) on ipv6
21-
net.createServer().listen({ host: '::', port: '3001' }).on('listening', common.mustCall(close));
2218
}
2319

2420
// Test listen(port, cb) and listen({ port }, cb) combinations
@@ -70,13 +66,6 @@ const listenOnPort = [
7066
name: 'TypeError',
7167
message: /^The argument 'options' must have the property "port" or "path"\. Received .+$/,
7268
});
73-
} else if (typeof options.host === 'string' && !options.host.match(/^[a-zA-Z0-9-:%.]+$/)) {
74-
assert.throws(fn,
75-
{
76-
code: 'ERR_INVALID_ARG_VALUE',
77-
name: 'TypeError',
78-
message: /^The argument 'host' is invalid\. Received .+$/,
79-
});
8069
} else {
8170
assert.throws(fn,
8271
{
@@ -102,5 +91,4 @@ const listenOnPort = [
10291
shouldFailToListen({ host: 'localhost:3000' });
10392
shouldFailToListen({ host: { port: 3000 } });
10493
shouldFailToListen({ exclusive: true });
105-
shouldFailToListen({ host: '[::]', port: 3000 });
10694
}

0 commit comments

Comments
 (0)