mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
http: llhttp opt-in insecure HTTP header parsing
Allow insecure HTTP header parsing. Make clear it is insecure. See: - https://github.com/nodejs/node/pull/30553 - https://github.com/nodejs/node/issues/27711#issuecomment-556265881 - https://github.com/nodejs/node/issues/30515 PR-URL: https://github.com/nodejs/node/pull/30567 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
@@ -28,6 +28,8 @@ const {
|
||||
const { setImmediate } = require('timers');
|
||||
|
||||
const { methods, HTTPParser } = internalBinding('http_parser');
|
||||
const { getOptionValue } = require('internal/options');
|
||||
const insecureHTTPParser = getOptionValue('--insecure-http-parser');
|
||||
|
||||
const FreeList = require('internal/freelist');
|
||||
const incoming = require('_http_incoming');
|
||||
@@ -237,6 +239,16 @@ function prepareError(err, parser, rawPacket) {
|
||||
err.message = `Parse Error: ${err.reason}`;
|
||||
}
|
||||
|
||||
let warnedLenient = false;
|
||||
|
||||
function isLenient() {
|
||||
if (insecureHTTPParser && !warnedLenient) {
|
||||
warnedLenient = true;
|
||||
process.emitWarning('Using insecure HTTP parsing');
|
||||
}
|
||||
return insecureHTTPParser;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
_checkInvalidHeaderChar: checkInvalidHeaderChar,
|
||||
_checkIsHttpToken: checkIsHttpToken,
|
||||
@@ -249,5 +261,6 @@ module.exports = {
|
||||
parsers,
|
||||
kIncomingMessage,
|
||||
HTTPParser,
|
||||
isLenient,
|
||||
prepareError,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user