Skip to content

Commit 5b75323

Browse files
QUICHE teamcopybara-github
authored andcommitted
No public description
PiperOrigin-RevId: 723991213
1 parent 395814f commit 5b75323

File tree

2 files changed

+1
-29
lines changed

2 files changed

+1
-29
lines changed

quiche/common/structured_headers.cc

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "absl/strings/str_format.h"
2222
#include "absl/strings/string_view.h"
2323
#include "absl/types/span.h"
24-
#include "quiche/common/platform/api/quiche_flag_utils.h"
2524
#include "quiche/common/platform/api/quiche_logging.h"
2625

2726
namespace quiche {
@@ -43,9 +42,6 @@ constexpr char kKeyChars09[] = DIGIT LCALPHA "_-";
4342
constexpr char kKeyChars[] = DIGIT LCALPHA "_-.*";
4443
constexpr char kSP[] = " ";
4544
constexpr char kOWS[] = " \t";
46-
// https://www.rfc-editor.org/rfc/rfc8941.html#section-4.2.7
47-
// https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-header-structure-09#section-4.2.11
48-
constexpr char kBase64Chars[] = DIGIT UCALPHA LCALPHA "+/=";
4945
#undef DIGIT
5046
#undef LCALPHA
5147
#undef UCALPHA
@@ -471,21 +467,7 @@ class StructuredHeaderParser {
471467
QUICHE_DVLOG(1) << "ReadByteSequence: missing closing delimiter";
472468
return std::nullopt;
473469
}
474-
475-
absl::string_view unpadded = input_.substr(0, len);
476-
// This check is partially redundant with the call to
477-
// `absl::Base64Unescape()` below, but unfortunately that function
478-
// allows `.` as a padding byte and does not reject ASCII whitespace, so it
479-
// cannot be used in isolation.
480-
if (unpadded.find_first_not_of(kBase64Chars) != absl::string_view::npos) {
481-
QUICHE_CODE_COUNT(structured_header_invalid_base64_char);
482-
// TODO(b/393153699, b/393408763): Early-return here to reject the invalid
483-
// input instead of silently proceeding.
484-
}
485-
486-
// TODO: This string copy shouldn't be necessary, as
487-
// `absl::Base64Unescape()` already handles the absence of padding.
488-
std::string base64(unpadded);
470+
std::string base64(input_.substr(0, len));
489471
// Append the necessary padding characters.
490472
base64.resize((base64.size() + 3) / 4 * 4, '=');
491473

quiche/common/structured_headers_test.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,6 @@ const struct ItemTestCase {
8585
{"c-style hex escape in string", "\"\\x61\"", std::nullopt, nullptr},
8686
{"valid quoting containing \\u", "\"\\\\u0061\"", Item("\\u0061"), nullptr},
8787
{"c-style unicode escape in string", "\"\\u0061\"", std::nullopt, nullptr},
88-
// TODO(b/393440282): Remove the following two tests once
89-
// structured_headers_generated_test.cc is updated to include them.
90-
// Manually copied from
91-
// https://github.com/httpwg/structured-field-tests/blob/d2ec605907058638faa895642063581939d84da6/binary.json#L40-L44
92-
// TODO(b/393153699): This input should be rejected.
93-
{"bad padding dot", ":YQ=.:", Item("a", Item::kByteSequenceType), ":YQ==:"},
94-
// Manually copied from
95-
// https://github.com/httpwg/structured-field-tests/blob/d2ec605907058638faa895642063581939d84da6/binary.json#L58-L62
96-
// TODO(b/393408763): This input should be rejected.
97-
{"all whitespace", ": :", Item("", Item::kByteSequenceType), "::"},
9888
};
9989

10090
const ItemTestCase sh09_item_test_cases[] = {

0 commit comments

Comments
 (0)