Automated g4 rollback of changelist 616801281.

*** Reason for rollback ***

Breaks Envoy

*** Original change description ***

Update ParseQuicTag to only use hex decoding if valid

ParseQuicTag was using absl::HexStringToBytes to unconditionally decode strings when they were 8 bytes long, but for strings with non-hexidecimal characters the return value of calling absl::HexStringToBytes is unspecified. This CL updates ParseQuicTag to only use the output of absl::HexStringToBytes when the call returns success.

This also moves the code away from using the deprecated version of absl::HexStringToBytes, allowing the Chrome...

***

PiperOrigin-RevId: 616910027
diff --git a/quiche/quic/core/quic_tag.cc b/quiche/quic/core/quic_tag.cc
index 27a71e4..e921dc4 100644
--- a/quiche/quic/core/quic_tag.cc
+++ b/quiche/quic/core/quic_tag.cc
@@ -5,16 +5,14 @@
 #include "quiche/quic/core/quic_tag.h"
 
 #include <algorithm>
-#include <cstddef>
-#include <cstdint>
 #include <string>
-#include <vector>
 
 #include "absl/base/macros.h"
 #include "absl/strings/ascii.h"
 #include "absl/strings/escaping.h"
 #include "absl/strings/str_split.h"
-#include "absl/strings/string_view.h"
+#include "quiche/quic/platform/api/quic_flag_utils.h"
+#include "quiche/quic/platform/api/quic_flags.h"
 #include "quiche/common/quiche_text_utils.h"
 
 namespace quic {
@@ -81,8 +79,8 @@
 QuicTag ParseQuicTag(absl::string_view tag_string) {
   quiche::QuicheTextUtils::RemoveLeadingAndTrailingWhitespace(&tag_string);
   std::string tag_bytes;
-  if (tag_string.length() == 8 &&
-      absl::HexStringToBytes(tag_string, &tag_bytes)) {
+  if (tag_string.length() == 8) {
+    tag_bytes = absl::HexStringToBytes(tag_string);
     tag_string = tag_bytes;
   }
   QuicTag tag = 0;
diff --git a/quiche/quic/core/quic_tag.h b/quiche/quic/core/quic_tag.h
index 2736aac..f130a57 100644
--- a/quiche/quic/core/quic_tag.h
+++ b/quiche/quic/core/quic_tag.h
@@ -50,13 +50,9 @@
 QUICHE_EXPORT std::string QuicTagToString(QuicTag tag);
 
 // Utility function that converts a string of the form "ABCD" to its
-// corresponding QuicTag. Note that `tag_string` will have leading and trailing
-// whitespace removed and will then be converted to a QuicTag as follows:
-//  - If the tag string is 8 bytes in length and all bytes are valid hexidecimal
-//    ASCII characters, then the returned QuicTag will have a corresponding
-//    hexidecimal value.
-//  - Otherwise, the QuicTag will be produced using the first four bytes of the
-//    tag string, right-padding with zeroes if there are fewer than four bytes.
+// corresponding QuicTag. Note that tags that are less than four characters
+// long are right-padded with zeroes. Tags that contain non-ASCII characters
+// are represented as 8-character-long hexadecimal strings.
 QUICHE_EXPORT QuicTag ParseQuicTag(absl::string_view tag_string);
 
 // Utility function that converts a string of the form "ABCD,EFGH" to a vector
diff --git a/quiche/quic/core/quic_tag_test.cc b/quiche/quic/core/quic_tag_test.cc
index 0337598..b3e6510 100644
--- a/quiche/quic/core/quic_tag_test.cc
+++ b/quiche/quic/core/quic_tag_test.cc
@@ -36,17 +36,13 @@
 TEST_F(QuicTagTest, ParseQuicTag) {
   QuicTag tag_abcd = MakeQuicTag('A', 'B', 'C', 'D');
   EXPECT_EQ(ParseQuicTag("ABCD"), tag_abcd);
-  EXPECT_EQ(ParseQuicTag(" ABCD "), tag_abcd);
   EXPECT_EQ(ParseQuicTag("ABCDE"), tag_abcd);
-  EXPECT_EQ(ParseQuicTag("ABCDEFGH"), tag_abcd);
   QuicTag tag_efgh = MakeQuicTag('E', 'F', 'G', 'H');
   EXPECT_EQ(ParseQuicTag("EFGH"), tag_efgh);
   QuicTag tag_ijk = MakeQuicTag('I', 'J', 'K', 0);
   EXPECT_EQ(ParseQuicTag("IJK"), tag_ijk);
   QuicTag tag_l = MakeQuicTag('L', 0, 0, 0);
   EXPECT_EQ(ParseQuicTag("L"), tag_l);
-  EXPECT_EQ(ParseQuicTag(" L"), tag_l);
-  EXPECT_EQ(ParseQuicTag("L "), tag_l);
   QuicTag tag_hex = MakeQuicTag('M', 'N', 'O', static_cast<char>(255));
   EXPECT_EQ(ParseQuicTag("4d4e4fff"), tag_hex);
   EXPECT_EQ(ParseQuicTag("4D4E4FFF"), tag_hex);
@@ -56,7 +52,6 @@
   EXPECT_EQ(ParseQuicTag("r$_7"), tag_with_custom_chars);
   QuicTag tag_zero = 0;
   EXPECT_EQ(ParseQuicTag(""), tag_zero);
-  EXPECT_EQ(ParseQuicTag(" "), tag_zero);
   QuicTagVector tag_vector;
   EXPECT_EQ(ParseQuicTagVector(""), tag_vector);
   EXPECT_EQ(ParseQuicTagVector(" "), tag_vector);