From 954a4b4b5bb8a54b2e1d07105e4b2bb05a33e2ff Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 15 Feb 2016 09:40:58 -0800 Subject: [PATCH] deps: update to http-parser 2.6.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes http-parser regression with IS_HEADER_CHAR check Add test case for obstext characters (> 0x80) is header PR-URL: https://github.com/nodejs/node/pull/5237 Reviewed-By: Ben Noordhuis Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Myles Borins --- deps/http_parser/Makefile | 4 ++-- deps/http_parser/http_parser.c | 2 +- deps/http_parser/http_parser.h | 2 +- deps/http_parser/test.c | 2 +- test/parallel/test-http-header-obstext.js | 18 ++++++++++++++++++ 5 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 test/parallel/test-http-header-obstext.js diff --git a/deps/http_parser/Makefile b/deps/http_parser/Makefile index b3e0ff4ae0dbe3..970bdc42635ae1 100644 --- a/deps/http_parser/Makefile +++ b/deps/http_parser/Makefile @@ -22,14 +22,14 @@ PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"') HELPER ?= BINEXT ?= ifeq (darwin,$(PLATFORM)) -SONAME ?= libhttp_parser.2.6.1.dylib +SONAME ?= libhttp_parser.2.6.2.dylib SOEXT ?= dylib else ifeq (wine,$(PLATFORM)) CC = winegcc BINEXT = .exe.so HELPER = wine else -SONAME ?= libhttp_parser.so.2.6.1 +SONAME ?= libhttp_parser.so.2.6.2 SOEXT ?= so endif diff --git a/deps/http_parser/http_parser.c b/deps/http_parser/http_parser.c index 33d29bb1751a76..852bed042e9b21 100644 --- a/deps/http_parser/http_parser.c +++ b/deps/http_parser/http_parser.c @@ -440,7 +440,7 @@ enum http_host_state * character or %x80-FF **/ #define IS_HEADER_CHAR(ch) \ - (ch == CR || ch == LF || ch == 9 || (ch > 31 && ch != 127)) + (ch == CR || ch == LF || ch == 9 || ((unsigned char)ch > 31 && ch != 127)) #define start_state (parser->type == HTTP_REQUEST ? s_start_req : s_start_res) diff --git a/deps/http_parser/http_parser.h b/deps/http_parser/http_parser.h index e33c0620a1459c..0cee4cc85b3892 100644 --- a/deps/http_parser/http_parser.h +++ b/deps/http_parser/http_parser.h @@ -27,7 +27,7 @@ extern "C" { /* Also update SONAME in the Makefile whenever you change these. */ #define HTTP_PARSER_VERSION_MAJOR 2 #define HTTP_PARSER_VERSION_MINOR 6 -#define HTTP_PARSER_VERSION_PATCH 1 +#define HTTP_PARSER_VERSION_PATCH 2 #include #if defined(_WIN32) && !defined(__MINGW32__) && \ diff --git a/deps/http_parser/test.c b/deps/http_parser/test.c index 87345bb0dc5b6c..26092411c7e16a 100644 --- a/deps/http_parser/test.c +++ b/deps/http_parser/test.c @@ -3356,7 +3356,7 @@ test_double_content_length_error (int req) parsed = http_parser_execute(&parser, &settings_null, buf, buflen); if (parsed != buflen) { - assert(HTTP_PARSER_ERRNO(&parser) == HPE_MULTIPLE_CONTENT_LENGTH); + assert(HTTP_PARSER_ERRNO(&parser) == HPE_UNEXPECTED_CONTENT_LENGTH); return; } diff --git a/test/parallel/test-http-header-obstext.js b/test/parallel/test-http-header-obstext.js new file mode 100644 index 00000000000000..ba28768be320e6 --- /dev/null +++ b/test/parallel/test-http-header-obstext.js @@ -0,0 +1,18 @@ +'use strict'; + +const common = require('../common'); +const http = require('http'); +const assert = require('assert'); + +const server = http.createServer(common.mustCall((req, res) => { + res.end('ok'); +})); +server.listen(common.PORT, () => { + http.get({ + port: common.PORT, + headers: {'Test': 'Düsseldorf'} + }, common.mustCall((res) => { + assert.equal(res.statusCode, 200); + server.close(); + })); +});