Skip to content

Password with special characters throws a URI malformed exception #1317

@naphtul

Description

@naphtul

Describe the bug

  • Node.js version: 12.18.0
  • OS & version: MacOS 10.15.5

My password for the URL has special characters in it. It has the dollar sign ($) and the percent (%). These characters normally need to go through encodeURIComponent().

Actual behavior

RequestError: URI malformed
    at PromisableRequest._destroy (/node_modules/got/dist/source/core/index.js:1132:21)
    at PromisableRequest.destroy (internal/streams/destroy.js:38:8)
    at /node_modules/got/dist/source/core/index.js:288:26
    at new Request (/node_modules/got/dist/source/core/index.js:291:11)
    at new PromisableRequest (/node_modules/got/dist/source/as-promise/core.js:32:1)
    at makeRequest (/node_modules/got/dist/source/as-promise/index.js:37:29)
    at /node_modules/got/dist/source/as-promise/index.js:196:9
    at /node_modules/p-cancelable/index.js:61:11
    at new Promise (<anonymous>)
    at new PCancelable (/node_modules/p-cancelable/index.js:31:19)
    at decodeURI (<anonymous>)
    at /node_modules/got/dist/source/core/index.js:268:17
    at new Request (/node_modules/got/dist/source/core/index.js:291:11)
    at new PromisableRequest (/node_modules/got/dist/source/as-promise/core.js:32:1)
    at makeRequest (/node_modules/got/dist/source/as-promise/index.js:37:29)
    at /node_modules/got/dist/source/as-promise/index.js:196:9
    at /node_modules/p-cancelable/index.js:61:11
    at new Promise (<anonymous>)
    at new PCancelable (/node_modules/p-cancelable/index.js:31:19)
    at Object.asPromise [as default] (/node_modules/got/dist/source/as-promise/index.js:26:21)

Expected behavior

A password can have special characters in it, and the library should seamlessly handle it.

Code to reproduce

const got = require('got');
const url = 'https://enzmjqa4r8u7.x.pipedream.net';
const options = {
    username: 'test',
    password: 't$es%t',
};
response = got(url, options);

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething does not work as it shouldexternalThe issue related to an external projectnodejs bug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions