From eab75d0aa48759e8f2ec017b643e0ca6f985c937 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 6 Sep 2016 12:58:31 +0100 Subject: [PATCH] Bug 14060: Improve regex to limit year to 4 integers 01/01/01984 should not be considered as a valid date. Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall --- koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 7175df2a8b..aba713e9cd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -14,16 +14,16 @@ function is_valid_date(date) { var dateformat = dateformat_str = '[% Koha.Preference('dateformat') %]'; if ( dateformat == 'us' ) { - if ( date.search(/\d{2}\/\d{2}\/\d{4}/) == -1 ) return 0; + if ( date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1 ) return 0; dateformat = 'mm/dd/yy'; } else if ( dateformat == 'metric' ) { - if ( date.search(/\d{2}\/\d{2}\/\d{4}/) == -1 ) return 0; + if ( date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1 ) return 0; dateformat = 'dd/mm/yy'; } else if (dateformat == 'iso' ) { - if ( date.search(/\d{2}-\d{2}-\d{4}/) == -1 ) return 0; + if ( date.search(/^\d{2}-\d{2}-\d{4}($|\s)/) == -1 ) return 0; dateformat = 'yy-mm-dd'; } else if ( dateformat == 'dmydot' ) { - if ( date.search(/\d{2}\.\d{2}\.\d{4}/) == -1 ) return 0; + if ( date.search(/^\d{2}\.\d{2}\.\d{4}($|\s)/) == -1 ) return 0; dateformat = 'dd.mm.yy'; } try { -- 2.39.5