From 9b3a443477953fc253dc78feac5d03ce508627c7 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 Signed-off-by: Marcel de Rooy Signed-off-by: Fridolin Somers --- Koha/DateUtils.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm index bba8938499..58fec0bef9 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.39.5