From e875c8a41192cb5f40754ad473c7fa159df65aa3 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Mon, 6 May 2019 21:22:13 +0200 Subject: [PATCH] constants: add `|` to list of allowed URL chars The vertical bar character `|` wasn't ported from http-parser during rewrite. This commit introduces it back. See: https://github.com/nodejs/http-parser/blob/5c17dad400e45c5a442a63f250fff2638d144682/http_parser.c#L275 See: https://github.com/nodejs/node/issues/27584 --- src/llhttp/constants.ts | 2 +- test/request/uri.md | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/llhttp/constants.ts b/src/llhttp/constants.ts index 2c062310..8d6654df 100644 --- a/src/llhttp/constants.ts +++ b/src/llhttp/constants.ts @@ -153,7 +153,7 @@ export const STRICT_URL_CHAR: CharList = ([ ':', ';', '<', '=', '>', '@', '[', '\\', ']', '^', '_', '`', - '{', '}', '~', + '{', '|', '}', '~', ] as CharList).concat(ALPHANUM); export const URL_CHAR: CharList = STRICT_URL_CHAR diff --git a/test/request/uri.md b/test/request/uri.md index fc1ccffc..46a49318 100644 --- a/test/request/uri.md +++ b/test/request/uri.md @@ -67,6 +67,26 @@ off=51 headers complete method=1 v=1/1 flags=0 content_length=0 off=51 message complete ``` +## Query URL with vertical bar character + +It should be allowed to have vertical bar symbol in URI: `|`. + +See: https://github.com/nodejs/node/issues/27584 + + +```http +GET /test.cgi?query=| HTTP/1.1 + + +``` + +```log +off=0 message begin +off=4 len=17 span[url]="/test.cgi?query=|" +off=34 headers complete method=1 v=1/1 flags=0 content_length=0 +off=34 message complete +``` + ## `host:port` terminated by a space