File tree Expand file tree Collapse file tree 4 files changed +60
-2
lines changed Expand file tree Collapse file tree 4 files changed +60
-2
lines changed Original file line number Diff line number Diff line change @@ -2829,7 +2829,13 @@ This can be overridden for servers and client requests by passing the
2829
2829
<!-- YAML
2830
2830
added: v0.3.6
2831
2831
changes:
2832
- - version: v15.3.0
2832
+ - version: REPLACEME
2833
+ pr-url: https://github.com/nodejs/node/pull/39310
2834
+ description: When using a `URL` object parsed username and
2835
+ password will now be properly URI decoded.
2836
+ - version:
2837
+ - v15.3.0
2838
+ - v14.17.0
2833
2839
pr-url: https://github.com/nodejs/node/pull/36048
2834
2840
description: It is possible to abort a request with an AbortSignal.
2835
2841
- version:
Original file line number Diff line number Diff line change @@ -251,6 +251,10 @@ Global instance of [`https.Agent`][] for all HTTPS client requests.
251
251
<!-- YAML
252
252
added: v0.3.6
253
253
changes:
254
+ - version: REPLACEME
255
+ pr-url: https://github.com/nodejs/node/pull/39310
256
+ description: When using a `URL` object parsed username
257
+ and password will now be properly URI decoded.
254
258
- version:
255
259
- v14.1.0
256
260
- v13.14.0
Original file line number Diff line number Diff line change @@ -1303,7 +1303,7 @@ function urlToHttpOptions(url) {
1303
1303
options . port = Number ( url . port ) ;
1304
1304
}
1305
1305
if ( url . username || url . password ) {
1306
- options . auth = `${ url . username } :${ url . password } ` ;
1306
+ options . auth = `${ decodeURIComponent ( url . username ) } :${ decodeURIComponent ( url . password ) } ` ;
1307
1307
}
1308
1308
return options ;
1309
1309
}
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ require ( '../common' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+ const http = require ( 'http' ) ;
5
+
6
+ const testCases = [
7
+ {
8
+ username : 'test@test"' ,
9
+ password : '123456^' ,
10
+ expected : 'dGVzdEB0ZXN0IjoxMjM0NTZe'
11
+ } ,
12
+ {
13
+ username : 'test%40test' ,
14
+ password : '123456' ,
15
+ expected : 'dGVzdEB0ZXN0OjEyMzQ1Ng=='
16
+ } ,
17
+ {
18
+ username : 'not%3Agood' ,
19
+ password : 'god' ,
20
+ expected : 'bm90Omdvb2Q6Z29k'
21
+ } ,
22
+ {
23
+ username : 'not%22good' ,
24
+ password : 'g%5Eod' ,
25
+ expected : 'bm90Imdvb2Q6Z15vZA=='
26
+ } ,
27
+ {
28
+ username : 'test1234::::' ,
29
+ password : 'mypass' ,
30
+ expected : 'dGVzdDEyMzQ6Ojo6Om15cGFzcw=='
31
+ } ,
32
+ ] ;
33
+
34
+ for ( const testCase of testCases ) {
35
+ const server = http . createServer ( function ( request , response ) {
36
+ // The correct authorization header is be passed
37
+ assert . strictEqual ( request . headers . authorization , `Basic ${ testCase . expected } ` ) ;
38
+ response . writeHead ( 200 , { } ) ;
39
+ response . end ( 'ok' ) ;
40
+ server . close ( ) ;
41
+ } ) ;
42
+
43
+ server . listen ( 0 , function ( ) {
44
+ // make the request
45
+ const url = new URL ( `http://${ testCase . username } :${ testCase . password } @localhost:${ this . address ( ) . port } ` ) ;
46
+ http . request ( url ) . end ( ) ;
47
+ } ) ;
48
+ }
You can’t perform that action at this time.
0 commit comments