From 9101b8fb173e999511976c30c81e86dc35fdf4df Mon Sep 17 00:00:00 2001 From: Francesco Nigro Date: Sat, 16 Nov 2024 11:17:40 +0100 Subject: [PATCH] Improve HTTP validation for inlining and specialized types --- .../io/vertx/core/http/impl/HttpUtils.java | 188 +++++++++++++++--- 1 file changed, 157 insertions(+), 31 deletions(-) diff --git a/src/main/java/io/vertx/core/http/impl/HttpUtils.java b/src/main/java/io/vertx/core/http/impl/HttpUtils.java index 238341a1dcc..ada1b027ab7 100644 --- a/src/main/java/io/vertx/core/http/impl/HttpUtils.java +++ b/src/main/java/io/vertx/core/http/impl/HttpUtils.java @@ -863,7 +863,32 @@ public static void validateHeader(CharSequence name, Iterable 0x7f) { + throw new IllegalArgumentException("a header name cannot contain non-ASCII character: " + value); + } + if (!VALID_H_NAME_ASCII_CHARS[c & 0x7F]) { + throw new IllegalArgumentException("a header name cannot contain some prohibited characters, such as : " + value); + } + } + } + + private static void validateSequenceHeaderName(CharSequence value) { for (int i = 0; i < value.length(); i++) { final char c = value.charAt(i); // Check to see if the character is not an ASCII character, or invalid