From 13390d62fb4af5e51fe9b0fee194fd07f424d4f1 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 Content-Type: text/plain; charset=utf-8 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 --- 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.20.1