File tree 4 files changed +11
-24
lines changed
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
+
1
7
4.19.2 / 2024-03-25
2
8
==========
3
9
Original file line number Diff line number Diff line change @@ -55,7 +55,6 @@ module.exports = res
55
55
*/
56
56
57
57
var charsetRegExp = / ; \s * c h a r s e t \s * = / ;
58
- var schemaAndHostRegExp = / ^ (?: [ a - z A - Z ] [ a - z A - Z 0 - 9 + . - ] * : ) ? \/ \/ [ ^ \\ \/ \? ] + / ;
59
58
60
59
/**
61
60
* Set status `code`.
@@ -914,14 +913,7 @@ res.location = function location(url) {
914
913
loc = String ( url ) ;
915
914
}
916
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 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 ) ) ;
925
917
} ;
926
918
927
919
/**
Original file line number Diff line number Diff line change 37
37
"cookie-signature" : " 1.0.6" ,
38
38
"debug" : " 2.6.9" ,
39
39
"depd" : " 2.0.0" ,
40
- "encodeurl" : " ~1 .0.2 " ,
40
+ "encodeurl" : " ~2 .0.0 " ,
41
41
"escape-html" : " ~1.0.3" ,
42
42
"etag" : " ~1.8.1" ,
43
43
"finalhandler" : " 1.2.0" ,
Original file line number Diff line number Diff line change @@ -293,23 +293,12 @@ describe('res', function(){
293
293
) ;
294
294
} ) ;
295
295
296
- it ( 'should percent encode backslashes in the path' , function ( done ) {
296
+ it ( 'should keep backslashes in the path' , function ( done ) {
297
297
var app = createRedirectServerForDomain ( 'google.com' ) ;
298
298
testRequestedRedirect (
299
299
app ,
300
300
'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' ,
313
302
'google.com' ,
314
303
done
315
304
) ;
@@ -364,7 +353,7 @@ describe('res', function(){
364
353
testRequestedRedirect (
365
354
app ,
366
355
'file:///etc\\passwd' ,
367
- 'file:///etc%5Cpasswd ' ,
356
+ 'file:///etc\\passwd ' ,
368
357
'' ,
369
358
done
370
359
) ;
You can’t perform that action at this time.
0 commit comments