Removes tracking of invalid character counts in BalsaFrame. This is no longer used after cl/647679150. Protected by removes an unused feature; not protected. PiperOrigin-RevId: 647738885
diff --git a/quiche/balsa/balsa_frame.cc b/quiche/balsa/balsa_frame.cc index f4a34b8..e77bb5d 100644 --- a/quiche/balsa/balsa_frame.cc +++ b/quiche/balsa/balsa_frame.cc
@@ -74,7 +74,6 @@ term_chars_ = 0; parse_state_ = BalsaFrameEnums::READING_HEADER_AND_FIRSTLINE; last_error_ = BalsaFrameEnums::BALSA_NO_ERROR; - invalid_chars_.clear(); lines_.clear(); if (continue_headers_ != nullptr) { continue_headers_->Clear(); @@ -659,13 +658,11 @@ for (const char* c = stream_begin; c < stream_end; c++) { if (header_properties::IsInvalidHeaderChar(*c)) { found_invalid = true; - invalid_chars_[*c]++; } if (*c == '\r' && http_validation_policy().disallow_lone_cr_in_request_headers && c + 1 < stream_end && *(c + 1) != '\n') { found_invalid = true; - invalid_chars_[*c]++; } }
diff --git a/quiche/balsa/balsa_frame.h b/quiche/balsa/balsa_frame.h index a7cbd6a..27eea6b 100644 --- a/quiche/balsa/balsa_frame.h +++ b/quiche/balsa/balsa_frame.h
@@ -11,7 +11,6 @@ #include <utility> #include <vector> -#include "absl/container/flat_hash_map.h" #include "quiche/balsa/balsa_enums.h" #include "quiche/balsa/balsa_headers.h" #include "quiche/balsa/balsa_visitor_interface.h" @@ -164,10 +163,6 @@ BalsaFrameEnums::ErrorCode ErrorCode() const { return last_error_; } - const absl::flat_hash_map<char, int>& get_invalid_chars() const { - return invalid_chars_; - } - const BalsaHeaders* headers() const { return headers_; } BalsaHeaders* mutable_headers() { return headers_; } @@ -217,7 +212,6 @@ BalsaHeaders* headers); // Returns true if there are invalid characters, false otherwise. - // Will also update counts per invalid character in invalid_chars_. bool CheckHeaderLinesForInvalidChars(const Lines& lines, const BalsaHeaders* headers); @@ -290,7 +284,6 @@ uint32_t term_chars_; BalsaFrameEnums::ParseState parse_state_; BalsaFrameEnums::ErrorCode last_error_; - absl::flat_hash_map<char, int> invalid_chars_; Lines lines_;
diff --git a/quiche/balsa/balsa_frame_test.cc b/quiche/balsa/balsa_frame_test.cc index 095c727..f3f8eb1 100644 --- a/quiche/balsa/balsa_frame_test.cc +++ b/quiche/balsa/balsa_frame_test.cc
@@ -987,8 +987,6 @@ CreateMessage("GET / \rHTTP/1.1\r\n", headers, 2, ":", "\r\n", ""); framer.ProcessInput(message.data(), message.size()); EXPECT_EQ(framer.ErrorCode(), BalsaFrameEnums::INVALID_HEADER_CHARACTER); - // One carriage return in firstline, 1 in header value. - EXPECT_EQ(framer.get_invalid_chars().at('\r'), 2); } // Test that lone '\r' detection works correctly in the firstline @@ -1008,7 +1006,6 @@ EXPECT_EQ(message2.size(), framer.ProcessInput(message2.data(), message2.size())); EXPECT_EQ(framer.ErrorCode(), BalsaFrameEnums::INVALID_HEADER_CHARACTER); - EXPECT_EQ(framer.get_invalid_chars().at('\r'), 1); } // Test that lone '\r' detection works correctly in header values @@ -1028,7 +1025,6 @@ EXPECT_EQ(message2.size(), framer.ProcessInput(message2.data(), message2.size())); EXPECT_EQ(framer.ErrorCode(), BalsaFrameEnums::INVALID_HEADER_CHARACTER); - EXPECT_EQ(framer.get_invalid_chars().at('\r'), 1); } TEST(HTTPBalsaFrame, CarriageReturnIllegalInHeaderKey) { @@ -4063,14 +4059,12 @@ HandleWarning(BalsaFrameEnums::INVALID_HEADER_CHARACTER)) .Times(0); balsa_frame_.ProcessInput(message.data(), message.size()); - EXPECT_THAT(balsa_frame_.get_invalid_chars(), IsEmpty()); } else { // invalid char absl::flat_hash_map<char, int> expected_count = {{c, 1}}; EXPECT_CALL(visitor_mock_, HandleWarning(BalsaFrameEnums::INVALID_HEADER_CHARACTER)); balsa_frame_.ProcessInput(message.data(), message.size()); - EXPECT_EQ(balsa_frame_.get_invalid_chars(), expected_count); } EXPECT_FALSE(balsa_frame_.Error()); EXPECT_TRUE(balsa_frame_.MessageFullyRead()); @@ -4110,7 +4104,7 @@ EXPECT_TRUE(balsa_frame_.MessageFullyRead()); } -TEST_F(HTTPBalsaFrameTest, InvalidCharsAreCounted) { +TEST_F(HTTPBalsaFrameTest, InvalidCharsAreDetected) { balsa_frame_.set_invalid_chars_level(BalsaFrame::InvalidCharsLevel::kWarning); const std::string kInvalid1 = "GET /foo \\x00\\x00\\x00HTTP/1.1\r\n" @@ -4121,14 +4115,8 @@ EXPECT_CALL(visitor_mock_, HandleWarning(BalsaFrameEnums::INVALID_HEADER_CHARACTER)); balsa_frame_.ProcessInput(message.data(), message.size()); - absl::flat_hash_map<char, int> expected_count = {{'\0', 4}, {'\4', 2}}; EXPECT_FALSE(balsa_frame_.Error()); EXPECT_TRUE(balsa_frame_.MessageFullyRead()); - EXPECT_EQ(balsa_frame_.get_invalid_chars(), expected_count); - - absl::flat_hash_map<char, int> empty_count; - balsa_frame_.Reset(); - EXPECT_EQ(balsa_frame_.get_invalid_chars(), empty_count); } // Test gibberish in headers and trailer. GFE does not crash but garbage in