diff --git a/src/common/time/parser/datetime_scanner.lex b/src/common/time/parser/datetime_scanner.lex index 0e14cbb66ce..6df2f8321d4 100644 --- a/src/common/time/parser/datetime_scanner.lex +++ b/src/common/time/parser/datetime_scanner.lex @@ -59,7 +59,7 @@ R_BRACKET "]" return TokenType::TIME_ZONE_NAME; } -. { +\n|. { /** * Any other unmatched byte sequences will get us here, * including the non-ascii ones, which are negative diff --git a/src/common/time/parser/test/DateTimeParserTest.cpp b/src/common/time/parser/test/DateTimeParserTest.cpp index 44acb835a14..939441b48b4 100644 --- a/src/common/time/parser/test/DateTimeParserTest.cpp +++ b/src/common/time/parser/test/DateTimeParserTest.cpp @@ -83,6 +83,16 @@ TEST(DatetimeReader, DateTimeFailed) { auto result = parser.readDatetime("2019-01-03T22:22:3.2333x"); EXPECT_FALSE(result.ok()) << result.value(); } + { + auto parser = time::DatetimeReader::makeDateTimeReader(); + auto result = parser.readDatetime("2019-01-03T22:22:3.2333\n"); + EXPECT_FALSE(result.ok()) << result.value(); + } + { + auto parser = time::DatetimeReader::makeDateTimeReader(); + auto result = parser.readDatetime("\t2019-01-03T22:22:3.2333"); + EXPECT_FALSE(result.ok()) << result.value(); + } // not ending delimiter { auto parser = time::DatetimeReader::makeDateTimeReader(); @@ -150,6 +160,16 @@ TEST(DatetimeReader, DateFailed) { auto result = parser.readDate("2019-01-03*"); EXPECT_FALSE(result.ok()) << result.value(); } + { + auto parser = time::DatetimeReader::makeDateReader(); + auto result = parser.readDate("2019-01-03\n"); + EXPECT_FALSE(result.ok()) << result.value(); + } + { + auto parser = time::DatetimeReader::makeDateReader(); + auto result = parser.readDate("\t2019-01-03"); + EXPECT_FALSE(result.ok()) << result.value(); + } // extra components { auto parser = time::DatetimeReader::makeDateReader(); @@ -227,6 +247,16 @@ TEST(DatetimeReader, TimeFailed) { auto result = parser.readTime("22:22:3.2333x"); EXPECT_FALSE(result.ok()) << result.value(); } + { + auto parser = time::DatetimeReader::makeTimeReader(); + auto result = parser.readTime("22:22:3.2333\n"); + EXPECT_FALSE(result.ok()) << result.value(); + } + { + auto parser = time::DatetimeReader::makeTimeReader(); + auto result = parser.readTime("\t22:22:3.2333\n"); + EXPECT_FALSE(result.ok()) << result.value(); + } // extra components { auto parser = time::DatetimeReader::makeTimeReader();