Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: unshiftio/url-parse
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: eb6d9f51e395b7e47bf2594e457d541db21c713b
Choose a base ref
...
head repository: unshiftio/url-parse
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8b3f5f2c88a4cfc2880f2319c307994cb25bb10a
Choose a head ref

Commits on May 13, 2021

  1. Copy the full SHA
    af84da0 View commit details

Commits on May 15, 2021

  1. Copy the full SHA
    9f43f43 View commit details

Commits on May 18, 2021

  1. [fix] Special case the file: protocol (#204)

    Fixes #203
    lpinca authored May 18, 2021
    Copy the full SHA
    d2979b5 View commit details

Commits on Jun 3, 2021

  1. [ci] Use GitHub Actions

    lpinca committed Jun 3, 2021
    Copy the full SHA
    ee22050 View commit details

Commits on Jul 24, 2021

  1. Copy the full SHA
    81ab967 View commit details
  2. [fix] Do not incorrectly set the slashes property to true

    Set it to `true` only if the protocol is special or if it is actually
    followed by two forward slashes.
    lpinca committed Jul 24, 2021
    Copy the full SHA
    94872e7 View commit details
  3. [fix] Add a leading slash only if the URL is special

    If the value of the `pathname` property does not start with a `/`, add
    it only if the URL is special.
    lpinca committed Jul 24, 2021
    Copy the full SHA
    fed6d9e View commit details
  4. Copy the full SHA
    fb128af View commit details

Commits on Jul 25, 2021

  1. Copy the full SHA
    2d9ac2c View commit details
  2. [dist] 1.5.2

    3rd-Eden committed Jul 25, 2021
    Copy the full SHA
    201034b View commit details
  3. 1
    Copy the full SHA
    c798461 View commit details
  4. [dist] 1.5.3

    3rd-Eden committed Jul 25, 2021
    1
    Copy the full SHA
    ad44493 View commit details

Commits on Aug 8, 2021

  1. Copy the full SHA
    78f7017 View commit details

Commits on Aug 14, 2021

  1. [fix] Do not add spurious slashes

    The forward slashes are not removed if there is no protocol so they must
    not be added back when the `Url` object is stringified.
    lpinca committed Aug 14, 2021
    3
    Copy the full SHA
    d9e332b View commit details
  2. [fix] Handle the auth property (#213)

    Update the value of the `username` and `password` properties when the
    `auth` property is set.
    
    Fixes #212
    bluelovers authored Aug 14, 2021
    Copy the full SHA
    993acbe View commit details
  3. [fix] Do not lose the password in the stringification process

    Handle the case where the value of the `username` property is empty and
    the value of the `password` property is non-empty.
    lpinca committed Aug 14, 2021
    Copy the full SHA
    15b1dbd View commit details
  4. [test] Test that Url#set() correctly handles the auth property

    Test that when the value of the `auth` property is updated, the values
    of the `username` and `password` properties are also updated.
    
    Refs: #213
    lpinca committed Aug 14, 2021
    Copy the full SHA
    0be9572 View commit details

Commits on Aug 23, 2021

  1. [fix] Handle the username and password properties

    Update the value of the `auth` property when the `username` or
    `password` property is set.
    
    Refs: #213 (comment)
    lpinca committed Aug 23, 2021
    Copy the full SHA
    53d4d6d View commit details
  2. [minor] Remove dead code

    lpinca committed Aug 23, 2021
    Copy the full SHA
    5472388 View commit details
  3. Copy the full SHA
    36dd8b4 View commit details

Commits on Sep 15, 2021

  1. Copy the full SHA
    e9a8353 View commit details

Commits on Oct 4, 2021

  1. Copy the full SHA
    a72a5c6 View commit details

Commits on Oct 28, 2021

  1. [ci] Test on node 17

    lpinca committed Oct 28, 2021
    1
    Copy the full SHA
    5e8a444 View commit details

Commits on Nov 11, 2021

  1. Copy the full SHA
    e324874 View commit details

Commits on Dec 28, 2021

  1. [dist] 1.5.4

    3rd-Eden authored Dec 28, 2021
    Copy the full SHA
    82c4908 View commit details

Commits on Jan 9, 2022

  1. Copy the full SHA
    f7774f6 View commit details

Commits on Jan 30, 2022

  1. Copy the full SHA
    9be7ee8 View commit details

Commits on Feb 11, 2022

  1. Copy the full SHA
    4e53a8c View commit details

Commits on Feb 13, 2022

  1. [fix] Remove CR, HT, and LF

    Copy the behavior of browser `URL` interface and remove CR, HT, and LF
    from the input URL.
    lpinca committed Feb 13, 2022
    Copy the full SHA
    319851b View commit details
  2. Copy the full SHA
    193b44b View commit details
  3. 1.5.5

    Swaagie committed Feb 13, 2022
    Copy the full SHA
    e4a5807 View commit details
  4. Merge pull request #223 from unshiftio/fix/at-sign-handling-in-userinfo

    Correctly handle userinfo containing the at sign
    Swaagie authored Feb 13, 2022
    Copy the full SHA
    7b0b8a6 View commit details
  5. 1.5.6

    Swaagie committed Feb 13, 2022
    Copy the full SHA
    4c9fa23 View commit details
  6. Copy the full SHA
    e6fa434 View commit details
  7. [security] Fix nits

    lpinca committed Feb 13, 2022
    Copy the full SHA
    78e9f2f View commit details

Commits on Feb 16, 2022

  1. Copy the full SHA
    88df234 View commit details
  2. [fix] Readd the empty userinfo to url.href (#226)

    If the userinfo is present but empty, the parsed host is also empty, and
    `url.pathname` is not `'/'`, then readd the empty userinfo to `url.href`,
    otherwise the original invalid URL might be transformed into a valid one
    with `url.pathname` as host.
    lpinca authored Feb 16, 2022
    Copy the full SHA
    ef45a13 View commit details
  3. 1.5.7

    Swaagie committed Feb 16, 2022
    Copy the full SHA
    8b3f5f2 View commit details
Showing with 648 additions and 70 deletions.
  1. +39 −0 .github/workflows/ci.yml
  2. +0 −25 .travis.yml
  3. +9 −3 README.md
  4. +25 −0 SECURITY.md
  5. +140 −26 index.js
  6. +4 −5 package.json
  7. +1 −1 test/browser.js
  8. +430 −10 test/test.js
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
- push
- pull_request

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node:
- 12
- 14
- 16
- 17
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm test
- uses: coverallsapp/github-action@1.1.3
if: matrix.node == 12
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
test-browser:
runs-on: ubuntu-latest
env:
SAUCE_USERNAME: url-parse
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm install
- run: npm run test-browser
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# url-parse

[![Made by unshift](https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square)](http://unshift.io)[![Version npm](https://img.shields.io/npm/v/url-parse.svg?style=flat-square)](https://www.npmjs.com/package/url-parse)[![Build Status](https://img.shields.io/travis/unshiftio/url-parse/master.svg?style=flat-square)](https://travis-ci.org/unshiftio/url-parse)[![Dependencies](https://img.shields.io/david/unshiftio/url-parse.svg?style=flat-square)](https://david-dm.org/unshiftio/url-parse)[![Coverage Status](https://img.shields.io/coveralls/unshiftio/url-parse/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/url-parse?branch=master)[![IRC channel](https://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square)](https://webchat.freenode.net/?channels=unshift)
[![Version npm](https://img.shields.io/npm/v/url-parse.svg?style=flat-square)](https://www.npmjs.com/package/url-parse)[![Build Status](https://img.shields.io/github/workflow/status/unshiftio/url-parse/CI/master?label=CI&style=flat-square)](https://github.com/unshiftio/url-parse/actions?query=workflow%3ACI+branch%3Amaster)[![Coverage Status](https://img.shields.io/coveralls/unshiftio/url-parse/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/url-parse?branch=master)

[![Sauce Test Status](https://saucelabs.com/browser-matrix/url-parse.svg)](https://saucelabs.com/u/url-parse)

**`url-parse` was created in 2014 when the WHATWG URL API was not available in
Node.js and the `URL` interface was supported only in some browsers. Today this
is no longer true. The `URL` interface is available in all supported Node.js
release lines and basically all browsers. Consider using it for better security
and accuracy.**

The `url-parse` method exposes two different API interfaces. The
[`url`](https://nodejs.org/api/url.html) interface that you know from Node.js
and the new [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL)
@@ -80,8 +86,8 @@ The returned `url` instance contains the following properties:
- `auth`: Authentication information portion (e.g. `username:password`).
- `username`: Username of basic authentication.
- `password`: Password of basic authentication.
- `host`: Host name with port number.
- `hostname`: Host name without port number.
- `host`: Host name with port number. The hostname might be invalid.
- `hostname`: Host name without port number. This might be an invalid hostname.
- `port`: Optional port number.
- `pathname`: URL path.
- `query`: Parsed object containing query string, unless parsing is set to false.
25 changes: 25 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -33,6 +33,29 @@ acknowledge your responsible disclosure, if you wish.

## History

> Incorrect handling of username and password can lead to authorization bypass.
- **Reporter credits**
- ranjit-git
- GitHub: [@ranjit-git](https://github.com/ranjit-git)
- Huntr report: https://www.huntr.dev/bounties/6d1bc51f-1876-4f5b-a2c2-734e09e8e05b/
- Fixed in: 1.5.6

---

> url-parse mishandles certain uses of a single (back) slash such as https:\ &
> https:/ and interprets the URI as a relative path. Browsers accept a single
> backslash after the protocol, and treat it as a normal slash, while url-parse
> sees it as a relative path.
- **Reporter credits**
- ready-research
- GitHub: [@ready-research](https://github.com/ready-research)
- Huntr report: https://www.huntr.dev/bounties/1625557993985-unshiftio/url-parse/
- Fixed in: 1.5.2

---

> Using backslash in the protocol is valid in the browser, while url-parse
> thinks it’s a relative path. An application that validates a url using
> url-parse might pass a malicious link.
@@ -42,6 +65,8 @@ acknowledge your responsible disclosure, if you wish.
- Twitter: [Yaniv Nizry](https://twitter.com/ynizry)
- Fixed in: 1.5.0

---

> The `extractProtocol` method does not return the correct protocol when
> provided with unsanitized content which could lead to false positives.
Loading