Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

url.parse does not handle IPv6 link-local addresses correctly #9404

Closed
@cthayer

Description

@cthayer

In version 0.12.0, url.parse() does not parse a URL containing an IPv6 link-local address correctly.

Specifically, adding a zone to the address in the host portion of the URL causes url.parse() to fail to detect the host portion of the address and considers everything after the protocol to be part of the path.

Example of failure with IPv6 zone:

var url = require('url');

url.parse('ws://[fe80::2e0:4cff:fe68:23ff%en7]:51877/engine.io/?EIO=3&transport=websocket');
{ protocol: 'ws:',
  slashes: true,
  auth: null,
  host: '',
  port: null,
  hostname: '',
  hash: null,
  search: '?EIO=3&transport=websocket',
  query: 'EIO=3&transport=websocket',
  pathname: '/[fe80::2e0:4cff:fe68:23ff%en7]:51877/engine.io/',
  path: '/[fe80::2e0:4cff:fe68:23ff%en7]:51877/engine.io/?EIO=3&transport=websocket',
  href: 'ws:///[fe80::2e0:4cff:fe68:23ff%en7]:51877/engine.io/?EIO=3&transport=websocket' }

Example of success without the IPv6 zone:

var url = require('url');

url.parse('ws://[fe80::2e0:4cff:fe68:23ff]:51877/engine.io/?EIO=3&transport=websocket');
{ protocol: 'ws:',
  slashes: true,
  auth: null,
  host: '[fe80::2e0:4cff:fe68:23ff]:51877',
  port: '51877',
  hostname: 'fe80::2e0:4cff:fe68:23ff',
  hash: null,
  search: '?EIO=3&transport=websocket',
  query: 'EIO=3&transport=websocket',
  pathname: '/engine.io/',
  path: '/engine.io/?EIO=3&transport=websocket',
  href: 'ws://[fe80::2e0:4cff:fe68:23ff]:51877/engine.io/?EIO=3&transport=websocket' }

Expected behavior

I would expect url.parse() of ws://[fe80::2e0:4cff:fe68:23ff%en7]:51877/engine.io/?EIO=3&transport=websocket to produce the following result:

{ protocol: 'ws:',
  slashes: true,
  auth: null,
  host: '[fe80::2e0:4cff:fe68:23ff%en7]:51877',
  port: 51877,
  hostname: 'fe80::2e0:4cff:fe68:23ff%en7',
  hash: null,
  search: '?EIO=3&transport=websocket',
  query: 'EIO=3&transport=websocket',
  pathname: '/engine.io/',
  path: '/engine.io/?EIO=3&transport=websocket',
  href: 'ws://[fe80::2e0:4cff:fe68:23ff%en7]:51877/engine.io/?EIO=3&transport=websocket' }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions