Skip to content

Commit bf91946

Browse files
authored
deps: encodeurl@~2.0.0 (#5569)
1 parent d97d79e commit bf91946

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
lines changed

History.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
unreleased
2+
==========
3+
4+
* deps: encodeurl@~2.0.0
5+
- Removes encoding of `\`, `|`, and `^` to align better with URL spec
6+
17
4.19.2 / 2024-03-25
28
==========
39

lib/response.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ module.exports = res
5555
*/
5656

5757
var charsetRegExp = /;\s*charset\s*=/;
58-
var schemaAndHostRegExp = /^(?:[a-zA-Z][a-zA-Z0-9+.-]*:)?\/\/[^\\\/\?]+/;
5958

6059
/**
6160
* Set status `code`.
@@ -914,14 +913,7 @@ res.location = function location(url) {
914913
loc = String(url);
915914
}
916915

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 introduce
921-
// 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));
925917
};
926918

927919
/**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"cookie-signature": "1.0.6",
3838
"debug": "2.6.9",
3939
"depd": "2.0.0",
40-
"encodeurl": "~1.0.2",
40+
"encodeurl": "~2.0.0",
4141
"escape-html": "~1.0.3",
4242
"etag": "~1.8.1",
4343
"finalhandler": "1.2.0",

test/res.location.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,23 +293,12 @@ describe('res', function(){
293293
);
294294
});
295295

296-
it('should percent encode backslashes in the path', function (done) {
296+
it('should keep backslashes in the path', function (done) {
297297
var app = createRedirectServerForDomain('google.com');
298298
testRequestedRedirect(
299299
app,
300300
'https://google.com/foo\\bar\\baz',
301-
'https://google.com/foo%5Cbar%5Cbaz',
302-
'google.com',
303-
done
304-
);
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',
301+
'https://google.com/foo\\bar\\baz',
313302
'google.com',
314303
done
315304
);
@@ -364,7 +353,7 @@ describe('res', function(){
364353
testRequestedRedirect(
365354
app,
366355
'file:///etc\\passwd',
367-
'file:///etc%5Cpasswd',
356+
'file:///etc\\passwd',
368357
'',
369358
done
370359
);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy