From 0a175ae92c9b247862c4cfbb41335fe1d888ac24 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Tue, 11 Nov 2025 18:58:34 +0100 Subject: [PATCH] fix date length regex --- src/time_format.c | 2 +- tests/time_format_tests.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/time_format.c b/src/time_format.c index c49f3d6..cc862a2 100644 --- a/src/time_format.c +++ b/src/time_format.c @@ -10,7 +10,7 @@ #define SHORT_WEEKDAY_STR_LEN 3 #define MAX_TIME_STR_LENGTH 7 -#define DATE_REGEX "[0-9]{4}-([0][1-9]|1[0-2])-([0-2][1-9]|[1-3]0|3[01])" +#define DATE_REGEX "^[0-9]{4}-([0][1-9]|1[0-2])-([0-2][1-9]|[1-3]0|3[01])$" void get_time_str(time_t timediff, char* timestr) { diff --git a/tests/time_format_tests.c b/tests/time_format_tests.c index a6a8d78..0937a80 100644 --- a/tests/time_format_tests.c +++ b/tests/time_format_tests.c @@ -362,6 +362,7 @@ void validate_invalid_date_string_tests() validate_invalid_date_string("2025-01--1"); validate_invalid_date_string("2025-001-01"); validate_invalid_date_string("2025-001-011"); + validate_invalid_date_string("20255-01-11"); } int main() -- 2.47.3