From 62652115dc2b9263c9ac1d9067fdab240f96f9a1 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: Fridolin Somers --- Koha/DateUtils.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm index ad242b59eb..c4120b8c8f 100644 --- a/Koha/DateUtils.pm +++ b/Koha/DateUtils.pm @@ -162,6 +162,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 ) {