Repository navigation
Decode URL credentials in the patched http/https like Node.js - #130
Draft
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Draft
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Conversation
An extension that calls `https.get('https://user%40example.com:p%40ss@host/')` in VS Code sends `Authorization: Basic` with the still-encoded credentials `user%40example.com:p%40ss`, so the server rejects them with 401. Plain Node.js sends `user@example.com:p@ss`. A user name or password that contains `@`, `:`, `/`, `#`, `%` or a space has to be percent-encoded in a URL, so this hits every such credential. Why: when the patched `get`/`request` turns the URL into options, it sets `options.auth = `${parsed.username}:${parsed.password}``, but `URL.username` and `URL.password` are percent-encoded. Node.js' own `urlToHttpOptions` decodes them with `decodeURIComponent`. With the default `http.proxySupport` (`override`), every extension request goes through this code, also for direct connections.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Federico Brancasi (federicobrancasi)
requested a balanced review from Copilot
November 29, 2026 11:17
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the URL credential-decoding change.
No open issues 🎉
What changed in this PR
This PR aligns URL credential handling in the patched HTTP/HTTPS client with Node.js, fixing authentication failures when usernames or passwords contain percent-encoded characters.
Changes:
- Decode URL usernames and passwords before setting
options.auth. - Add a regression test comparing patched and native Node.js authentication.
- Document the fix in the changelog.
| File | Description |
|---|---|
| tests/src/createHttpPatch.test.ts | Tests decoded credentials against native Node.js behavior. |
| src/index.ts | Decodes URL credentials with decodeURIComponent. |
| CHANGELOG.md | Records the credential-decoding fix for version 0.46.1. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An extension that calls
https.get('https://user%40example.com:p%40ss@host/')in VS Code sendsAuthorization: Basicwith the still-encoded credentialsuser%40example.com:p%40ss, so the server rejects them with 401. Plain Node.js sendsuser@example.com:p@ss. A user name or password that contains@,:,/,#,%or a space has to be percent-encoded in a URL, so this hits every such credential. Why: when the patchedget/requestturns the URL into options, it setsoptions.auth =${parsed.username}:${parsed.password}``, butURL.usernameand `URL.password` are percent-encoded. Node.js' own `urlToHttpOptions` decodes them with `decodeURIComponent`. With the default `http.proxySupport` (`override`), every extension request goes through this code, also for direct connections.This PR decodes the user name and password with
decodeURIComponent, as Node.js does.How to test
npm run test:unitnpm run compile