Fix: Invalid HTTP/2 origin set when servername is empty #39919
The bug posted by @szmarczak is because of not checking the truthy value of options.servername
in line 3101 and 3102 of lib/internal/http2/core.js
, instead the options.servername
is strictly checked against undefined
, any value other than undefined
will give undesirable result in this case.
So in this PR,
if (servername !== undefined && options.servername === undefined)
options.servername = servername;
is changed to,
if (servername !== undefined && !options.servername)
options.servername = servername;
Here, the truthy value of options.servername
is checked rather than strict check against undefined
.
I have built node.js locally and checked against the code posted by @szmarczak to reproduce the bug.