Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/core/src/utils/dsn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { consoleSandbox, debug } from './debug-logger';
const ORG_ID_REGEX = /^o(\d+)\./;

/** Regular expression used to parse a Dsn. */
const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;
const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[0-9a-fA-F:]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: IPv6 DSN Parsing Fails for Mapped Addresses

The DSN_REGEX update for IPv6 addresses is too restrictive. The IPv6 host pattern [0-9a-fA-F:]+ is missing dots for IPv4-mapped IPv6 addresses and percent signs for zone identifiers, causing valid DSNs with these formats to fail parsing.

Fix in Cursor Fix in Web


function isValidProtocol(protocol?: string): protocol is DsnProtocol {
return protocol === 'http' || protocol === 'https';
Expand Down
5 changes: 4 additions & 1 deletion packages/node-core/src/transports/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,15 @@ function createRequestExecutor(
body = body.pipe(createGzip());
}

const hostnameIsIPv6 = hostname.startsWith('[');

const req = httpModule.request(
{
method: 'POST',
agent,
headers,
hostname,
// Remove "[" and "]" from IPv6 hostnames
hostname: hostnameIsIPv6 ? hostname.slice(1, -1) : hostname,
path: `${pathname}${search}`,
port,
protocol,
Expand Down
Loading