Import of CCTZ from GitHub.

Fixes #2014

PiperOrigin-RevId: 869283027
Change-Id: Ibd7ef8507a8968d1b35fc45a2f023a7d1bde7691
This commit is contained in:
Abseil Team
2026-02-12 10:37:59 -08:00
committed by Copybara-Service
parent 92b4141fef
commit 27a426287c
2 changed files with 4 additions and 1 deletions

View File

@@ -978,7 +978,7 @@ bool parse(const std::string& format, const std::string& input,
while (std::isspace(*data)) ++data;
// parse() must consume the entire input string.
if (*data != '\0') {
if (data != input.data() + input.size()) {
if (err != nullptr) *err = "Illegal trailing data in input string";
return false;
}

View File

@@ -967,6 +967,9 @@ TEST(Parse, ErrorCases) {
EXPECT_FALSE(parse("%Ez", "+-0:00", tz, &tp));
EXPECT_FALSE(parse("%z", "-00-0", tz, &tp));
EXPECT_FALSE(parse("%Ez", "-00:-0", tz, &tp));
// Check that we do not accept strings with embedded NULs.
EXPECT_FALSE(parse("%Y", std::string("2026\0payload", 12), tz, &tp));
}
TEST(Parse, PosixConversions) {