File tree Expand file tree Collapse file tree 4 files changed +11
-24
lines changed Expand file tree Collapse file tree 4 files changed +11
-24
lines changed Original file line number Diff line number Diff line change 1+ unreleased
2+ ==========
3+
4+ * deps: encodeurl@~ 2.0.0
5+ - Removes encoding of ` \ ` , ` | ` , and ` ^ ` to align better with URL spec
6+
174.19.2 / 2024-03-25
28==========
39
Original file line number Diff line number Diff line change @@ -55,7 +55,6 @@ module.exports = res
5555 */
5656
5757var charsetRegExp = / ; \s * c h a r s e t \s * = / ;
58- var schemaAndHostRegExp = / ^ (?: [ a - z A - Z ] [ a - z A - Z 0 - 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/**
Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments