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 <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Martin Renvoize 2021-11-03 12:15:18 +00:00 committed by Fridolin Somers
parent b09e3e99b7
commit 62652115dc

View file

@ -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 ) {