From 6b425ee38eb7790faa67b4f754bf5c217c75f32f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Thu, 1 Oct 2015 22:32:28 +0200 Subject: [PATCH] Bug 14923 - (follow-up) Test for invalid date input See comment #3 To test: - Make sure that you test on top of Bug 14936 (Add validation for date strings to Koha::DateUtils - Apply patch - Go to Home > Tools > Labels home > Manage label batches - Click "Add item(s)" - Verify that selection with date after and date before works the same as without patch. - Verify that you can not trigger a software error using invalid dates as 0000-00-00 or 32/01/1970 (copy/paste to date fields). --- labels/label-item-search.pl | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/labels/label-item-search.pl b/labels/label-item-search.pl index 7f67f51..efca8fe 100755 --- a/labels/label-item-search.pl +++ b/labels/label-item-search.pl @@ -78,26 +78,30 @@ if ( $op eq "do_search" ) { $dateto = $query->param('dateto'); if ($datefrom) { - $datefrom = output_pref({ dt => dt_from_string( $datefrom ), dateformat => 'iso', dateonly => 1 }); - if ($QParser) { - $ccl_query .= ' && ' if $ccl_textbox; - $ccl_query .= - "acqdate(" . $datefrom . '-)'; - } else { - $ccl_query .= ' and ' if $ccl_textbox; - $ccl_query .= - "acqdate,st-date-normalized,ge=" . $datefrom; + if ( is_formatted_date_string( $datefrom ) ) { + $datefrom = output_pref({ dt => dt_from_string( $datefrom ), dateformat => 'iso', dateonly => 1 }); + if ($QParser) { + $ccl_query .= ' && ' if $ccl_textbox; + $ccl_query .= + "acqdate(" . $datefrom . '-)'; + } else { + $ccl_query .= ' and ' if $ccl_textbox; + $ccl_query .= + "acqdate,st-date-normalized,ge=" . $datefrom; + } } } if ($dateto) { - $dateto = output_pref({ dt => dt_from_string( $dateto ), dateformat => 'iso', dateonly => 1 }); - if ($QParser) { - $ccl_query .= ' && ' if ( $ccl_textbox || $datefrom ); - $ccl_query .= "acqdate(-" . $dateto . ')'; - } else { - $ccl_query .= ' and ' if ( $ccl_textbox || $datefrom ); - $ccl_query .= "acqdate,st-date-normalized,le=" . $dateto; + if ( is_formatted_date_string( $datefrom ) ) { + $dateto = output_pref({ dt => dt_from_string( $dateto ), dateformat => 'iso', dateonly => 1 }); + if ($QParser) { + $ccl_query .= ' && ' if ( $ccl_textbox || $datefrom ); + $ccl_query .= "acqdate(-" . $dateto . ')'; + } else { + $ccl_query .= ' and ' if ( $ccl_textbox || $datefrom ); + $ccl_query .= "acqdate,st-date-normalized,le=" . $dateto; + } } } -- 1.7.10.4