File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -73,8 +73,9 @@ export class Parts {
7373 }
7474
7575 const uri = new URL ( `${ protocol } ://${ host } ${ message . url } ` ) ;
76+ const inferredPort = uri . port === "" ? ( protocol === "http" ? "80" : "443" ) : uri . port ;
7677
77- if ( uri . host !== host ) {
78+ if ( uri . host !== host && ` ${ uri . hostname } : ${ inferredPort } ` !== host ) {
7879 throw new Error ( `Host injection discovered: ${ host } ` ) ;
7980 }
8081
Original file line number Diff line number Diff line change @@ -111,6 +111,15 @@ describe("http:request", () => {
111111 / H o s t i n j e c t i o n d i s c o v e r e d : i n v a l i d @ h o s t / ,
112112 ) ;
113113 } ) ;
114+
115+ it ( "fromIncomingMessage throws no error on valid host with default port" , ( ) => {
116+ const message = new IncomingMessage ( ) ;
117+ message . method = "GET" ;
118+ message . headers [ "x-forwarded-proto" ] = "http" ;
119+ message . headers [ "x-forwarded-host" ] = "proxy.com:80" ;
120+
121+ Parts . fromIncomingMessage ( message , true ) ;
122+ } ) ;
114123 } ) ;
115124
116125 describe ( "HttpRequest" , ( ) => {
You can’t perform that action at this time.
0 commit comments