Skip to content
Myr

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

4 files+11 added−24 removed

modified:lib/response.js+1 added-9 removed
53 unmodified lines
54 * @private55 */5657var charsetRegExp = /;\s*charset\s*=/;58var schemaAndHostRegExp = /^(?:[a-zA-Z][a-zA-Z0-9+.-]*:)?\/\/[^\\\/\?]+/;5859/**60 * Set status `code`.61 *
850 unmodified lines
912 } else {913 loc = String(url);914 }915917 var m = schemaAndHostRegExp.exec(loc);918 var pos = m ? m[0].length + 1 : 0;919920 // 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));923924 return this.set('Location', loc);916 return this.set('Location', encodeUrl(loc));917};918919/**920 * Redirect to the given `url` with optional response `status`
250 unmodified lines
modified:test/res.location.js+3 added-14 removed
291 unmodified lines
292 done293 );294 });295296 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 });306307 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 });317307 it('should escape header splitting for old node versions', function (done) {308 var app = createRedirectServerForDomain('google.com');309 testRequestedRedirect(310 app,
41 unmodified lines
352 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 lines
modified:History.md+6 added
1unreleased2==========34 * deps: encodeurl@~2.0.05 - Removes encoding of `\`, `|`, and `^` to align better with URL spec674.19.2 / 2024-03-258==========910 * Improved fix for open redirect allow list bypass
3611 unmodified lines
modified:package.json+1 added-1 removed