Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/internal/tls/wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const {
ObjectSetPrototypeOf,
ReflectApply,
RegExp,
RegExpEscape,
Symbol,
SymbolFor,
} = primordials;
Expand Down Expand Up @@ -110,6 +111,8 @@ const kPskIdentityHint = Symbol('pskidentityhint');
const kPendingSession = Symbol('pendingSession');
const kIsVerified = Symbol('verified');

const kRegExpEscapedStar = RegExpEscape('*');

const noop = () => {};

let tlsTracingWarned = false;
Expand Down Expand Up @@ -1541,11 +1544,7 @@ Server.prototype.addContext = function(servername, context) {
throw new ERR_TLS_REQUIRED_SERVER_NAME();
}

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

const secureContext =
context instanceof common.SecureContext ? context : tls.createSecureContext(context);
Expand Down
Loading