Skip to content

Commit 3ab5c5d

Browse files
committed
fixup! tls: use RegExp.escape to better escape servername
1 parent 9e02b81 commit 3ab5c5d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/internal/tls/wrap.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ const kPskIdentityHint = Symbol('pskidentityhint');
111111
const kPendingSession = Symbol('pendingSession');
112112
const kIsVerified = Symbol('verified');
113113

114+
const kRegExpEscapedStar = RegExpEscape('*');
115+
114116
const noop = () => {};
115117

116118
let tlsTracingWarned = false;
@@ -1542,7 +1544,7 @@ Server.prototype.addContext = function(servername, context) {
15421544
throw new ERR_TLS_REQUIRED_SERVER_NAME();
15431545
}
15441546

1545-
const re = new RegExp(`^${RegExpEscape(servername).replace(/(?<=[^\\]|^)\\\*/g, '[^.]+')}$`);
1547+
const re = new RegExp(`^${RegExpEscape(servername).replaceAll(kRegExpEscapedStar, '[^.]+')}$`);
15461548

15471549
const secureContext =
15481550
context instanceof common.SecureContext ? context : tls.createSecureContext(context);

0 commit comments

Comments
 (0)