From 5344bc1c7eafec8e4f8ca4fca79ee1110a5be953 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 3 Nov 2021 12:15:18 +0000 Subject: [PATCH] Bug 29403: Match the whole string This patch wraps the constructed regex such that we expect the entire regex to match and don't allow leading or trailing garbage. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- Koha/DateUtils.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm index 0e8bd3c6fc6..71114c085a5 100644 --- a/Koha/DateUtils.pm +++ b/Koha/DateUtils.pm @@ -166,6 +166,10 @@ sub dt_from_string { $regex .= $time_re unless ( $date_format eq 'rfc3339' ); $fallback_re .= $time_re; + # Ensure we only accept date strings and not other characters. + $regex = '^' . $regex . '$'; + $fallback_re = '^' . $fallback_re . '$'; + my %dt_params; my $ampm; if ( $date_string =~ $regex ) { -- 2.25.1