deps: encodeurl@~2.0.0 (#5569)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Blake Embrey · committed by GitHub · parent d97d79e · Browse files · 4 files·+11 added−24 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+11 added−24 removed
- tests:+3 added−14 removed
- other:+8 added−10 removed
Provenance
- Commit
bf91946- Tree
0253fac- Author
Blake Embrey <hello@blakeembrey.com>- Committer
GitHub <noreply@github.com>- Parent
d97d79e
4 files changed+11 added−24 removed
modified:lib/response.js+1 added-9 removed
53 unmodified lines54 * @private55 */56 57 var charsetRegExp = /;\s*charset\s*=/;58-var schemaAndHostRegExp = /^(?:[a-zA-Z][a-zA-Z0-9+.-]*:)?\/\/[^\\\/\?]+/;58 59 /**60 * Set status `code`.61 *850 unmodified lines912 } else {913 loc = String(url);914 }915 917- var m = schemaAndHostRegExp.exec(loc);918- var pos = m ? m[0].length + 1 : 0;919-920- // Only encode after host to avoid invalid encoding which can introduce921- // vulnerabilities (e.g. `\\` to `%5C`).922- loc = loc.slice(0, pos) + encodeUrl(loc.slice(pos));923-924- return this.set('Location', loc);916+ return this.set('Location', encodeUrl(loc));917 };918 919 /**920 * Redirect to the given `url` with optional response `status`250 unmodified linesmodified:test/res.location.js+3 added-14 removed
291 unmodified lines292 done293 );294 });295 296- it('should percent encode backslashes in the path', function (done) {296+ it('should keep backslashes in the path', function (done) {297 var app = createRedirectServerForDomain('google.com');298 testRequestedRedirect(299 app,300 'https://google.com/foo\\bar\\baz',301- 'https://google.com/foo%5Cbar%5Cbaz',301+ 'https://google.com/foo\\bar\\baz',302 'google.com',303 done304 );305 });306 307- it('should encode backslashes in the path after the first backslash that triggered path parsing', function (done) {308- var app = createRedirectServerForDomain('google.com');309- testRequestedRedirect(310- app,311- 'https://google.com\\@app\\l\\e.com',312- 'https://google.com\\@app%5Cl%5Ce.com',313- 'google.com',314- done315- );316- });317-307 it('should escape header splitting for old node versions', function (done) {308 var app = createRedirectServerForDomain('google.com');309 testRequestedRedirect(310 app,41 unmodified lines352 var app = createRedirectServerForDomain('');353 testRequestedRedirect(354 app,355 'file:///etc\\passwd',367- 'file:///etc%5Cpasswd',356+ 'file:///etc\\passwd',357 '',358 done359 );360 });2 unmodified linesmodified:History.md+6 added
1+unreleased2+==========3+4+ * deps: encodeurl@~2.0.05+ - Removes encoding of `\`, `|`, and `^` to align better with URL spec6+7 4.19.2 / 2024-03-258 ==========9 10 * Improved fix for open redirect allow list bypass3611 unmodified linesmodified:package.json+1 added-1 removed
35 unmodified lines3637383940404142434454 unmodified lines35 unmodified lines "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", "encodeurl": "~1.0.2", "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "etag": "~1.8.1", "finalhandler": "1.2.0", "fresh": "0.5.2",54 unmodified lines