Always obeys BalsaFrame::invalid_chars_level_ when parsing header fields. The usage of HttpValidationPolicy::disallow_invalid_header_characters_in_response() in BalsaFrame is redundant: the only place it is set to true is in Envoy, which also sets InvalidCharsLevel::kError for responses. Protected by no functional change; not protected. PiperOrigin-RevId: 655623266
diff --git a/quiche/balsa/balsa_frame.cc b/quiche/balsa/balsa_frame.cc index d88e0e9..75fc510 100644 --- a/quiche/balsa/balsa_frame.cc +++ b/quiche/balsa/balsa_frame.cc
@@ -675,13 +675,10 @@ QUICHE_DCHECK(!lines.empty()); QUICHE_DVLOG(1) << "******@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@**********\n"; - if (is_request() || - http_validation_policy().disallow_invalid_header_characters_in_response) { - if (invalid_chars_error_enabled() && - CheckHeaderLinesForInvalidChars(lines, headers)) { - HandleError(BalsaFrameEnums::INVALID_HEADER_CHARACTER); - return; - } + if (invalid_chars_error_enabled() && + CheckHeaderLinesForInvalidChars(lines, headers)) { + HandleError(BalsaFrameEnums::INVALID_HEADER_CHARACTER); + return; } // There is no need to attempt to process headers (resp. trailers)
diff --git a/quiche/balsa/balsa_frame_test.cc b/quiche/balsa/balsa_frame_test.cc index 6a048a9..0d98476 100644 --- a/quiche/balsa/balsa_frame_test.cc +++ b/quiche/balsa/balsa_frame_test.cc
@@ -3999,7 +3999,7 @@ TEST_F(HTTPBalsaFrameTest, InvalidCharsInResponseHeaderAllowed) { balsa_frame_.set_is_request(false); - balsa_frame_.set_invalid_chars_level(BalsaFrame::InvalidCharsLevel::kError); + balsa_frame_.set_invalid_chars_level(BalsaFrame::InvalidCharsLevel::kOff); const absl::string_view headers = "HTTP/1.1 200 OK\r\n" @@ -4017,10 +4017,6 @@ balsa_frame_.set_is_request(false); balsa_frame_.set_invalid_chars_level(BalsaFrame::InvalidCharsLevel::kError); - HttpValidationPolicy http_validation_policy; - http_validation_policy.disallow_invalid_header_characters_in_response = true; - balsa_frame_.set_http_validation_policy(http_validation_policy); - const absl::string_view headers = "HTTP/1.1 200 OK\r\n" "Content-Length: 5\r\n"
diff --git a/quiche/balsa/http_validation_policy.h b/quiche/balsa/http_validation_policy.h index e26f2f2..33cdf7b 100644 --- a/quiche/balsa/http_validation_policy.h +++ b/quiche/balsa/http_validation_policy.h
@@ -49,6 +49,7 @@ // the character '"'. bool disallow_double_quote_in_header_name = false; + // TODO(b/314138604): remove this field once upstream Envoy stops using it // If true, then signal an INVALID_HEADER_CHARACTER warning or error, or // neither, depending on InvalidCharsLevel, if a response header contains an // invalid character. Invalid characters are always disallowed according to