From 3099c1b37c5d8d78fe562373244ef3b178fb81ba 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. --- 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 7175df2..aba713e 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.8.1