No public description PiperOrigin-RevId: 596940883
diff --git a/quiche/quic/core/http/quic_spdy_stream.cc b/quiche/quic/core/http/quic_spdy_stream.cc index 40ecc03..c38f6b0 100644 --- a/quiche/quic/core/http/quic_spdy_stream.cc +++ b/quiche/quic/core/http/quic_spdy_stream.cc
@@ -14,6 +14,7 @@ #include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" +#include "quiche/http2/adapter/header_validator.h" #include "quiche/http2/http2_constants.h" #include "quiche/quic/core/http/http_constants.h" #include "quiche/quic/core/http/http_decoder.h" @@ -1648,34 +1649,10 @@ namespace { -// Return true if |c| is not allowed in an HTTP/3 wire-encoded header and -// pseudo-header names according to -// https://datatracker.ietf.org/doc/html/draft-ietf-quic-http#section-4.1.1 and -// https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-semantics-19#section-5.6.2 -constexpr bool IsInvalidHeaderNameCharacter(unsigned char c) { - if (c == '!' || c == '|' || c == '~' || c == '*' || c == '+' || c == '-' || - c == '.' || - // #, $, %, &, ' - (c >= '#' && c <= '\'') || - // [0-9], : - (c >= '0' && c <= ':') || - // ^, _, `, [a-z] - (c >= '^' && c <= 'z')) { - return false; - } - return true; -} - -// Return true if `name` is invalid because it contains a disallowed character. -bool HeaderNameHasInvalidCharacter(absl::string_view name) { - const bool colon_invalid = - GetQuicReloadableFlag(quic_colon_invalid_in_header_name); - if (colon_invalid) { - QUICHE_RELOADABLE_FLAG_COUNT(quic_colon_invalid_in_header_name); - } - +// Return true if `name` only has allowed characters. +bool IsValidHeaderName(absl::string_view name) { if (name.empty()) { - return false; + return true; } // Remove leading colon of pseudo-headers. @@ -1684,16 +1661,7 @@ name.remove_prefix(1); } - if (std::find(name.begin(), name.end(), ':') != name.end()) { - // Header name contains colon (other than optional leading colon of - // pseudo-headers), which is invalid. - QUICHE_CODE_COUNT(quic_colon_in_header_name); - if (colon_invalid) { - return true; - } - } - - return std::any_of(name.begin(), name.end(), IsInvalidHeaderNameCharacter); + return http2::adapter::HeaderValidator::IsValidHeaderName(name); } } // namespace @@ -1712,7 +1680,7 @@ bool is_response = false; for (const std::pair<std::string, std::string>& pair : header_list) { const std::string& name = pair.first; - if (HeaderNameHasInvalidCharacter(name)) { + if (!IsValidHeaderName(name)) { invalid_request_details_ = absl::StrCat("Invalid character in header name ", name); QUIC_DLOG(ERROR) << invalid_request_details_;
diff --git a/quiche/quic/core/http/quic_spdy_stream_test.cc b/quiche/quic/core/http/quic_spdy_stream_test.cc index 47ffb69..42ca430 100644 --- a/quiche/quic/core/http/quic_spdy_stream_test.cc +++ b/quiche/quic/core/http/quic_spdy_stream_test.cc
@@ -3421,24 +3421,11 @@ EXPECT_EQ(0u, bytes_read); } -TEST_P(QuicSpdyStreamTest, ColonAllowedInHeaderName) { - if (!UsesHttp3()) { - return; - } - - SetQuicReloadableFlag(quic_colon_invalid_in_header_name, false); - Initialize(kShouldProcessData); - - headers_["foo:bar"] = "invalid"; - EXPECT_TRUE(stream_->ValidateReceivedHeaders(AsHeaderList(headers_))); -} - TEST_P(QuicSpdyStreamTest, ColonDisallowedInHeaderName) { if (!UsesHttp3()) { return; } - SetQuicReloadableFlag(quic_colon_invalid_in_header_name, true); Initialize(kShouldProcessData); headers_["foo:bar"] = "invalid";
diff --git a/quiche/quic/core/quic_flags_list.h b/quiche/quic/core/quic_flags_list.h index d890c10..bc0890b 100644 --- a/quiche/quic/core/quic_flags_list.h +++ b/quiche/quic/core/quic_flags_list.h
@@ -67,8 +67,6 @@ QUIC_FLAG(quic_reloadable_flag_quic_disable_server_blackhole_detection, false) // If true, disable resumption when receiving NRES connection option. QUIC_FLAG(quic_reloadable_flag_quic_enable_disable_resumption, true) -// If true, disallow colon in received header names (other than leading colon of pseudo-headers). -QUIC_FLAG(quic_reloadable_flag_quic_colon_invalid_in_header_name, true) // If true, discard INITIAL packet if the key has been dropped. QUIC_FLAG(quic_reloadable_flag_quic_discard_initial_packet_with_key_dropped, true) // If true, dispatcher sends error code QUIC_HANDSHAKE_FAILED_PACKETS_BUFFERED_TOO_LONG when handshake fails due to packets buffered for too long.