From 3232fbd8864ae988fb16fdce1fcbd46a32a158ae Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Thu, 19 May 2011 08:51:47 -0400 Subject: [PATCH] Make DATE_FORMAT macro check inputs Specifically, if no date and no format (empty replaces?) replace with empty string. Signed-off-by: Thomas Berezansky Signed-off-by: Jason Etheridge --- Open-ILS/xul/staff_client/chrome/content/util/print.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/print.js b/Open-ILS/xul/staff_client/chrome/content/util/print.js index 8c571c5922..28d78f9b97 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/print.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js @@ -305,9 +305,13 @@ util.print.prototype = { // Date Format try { var match; - var date_format_patt=/%DATE_FORMAT\(([^,]*),([^)]*)\)%/ - while(match = date_format_patt.exec(s)) - s = s.replace(match[0], util.date.formatted_date(match[1], match[2])); + var date_format_patt=/%DATE_FORMAT\(\s*([^,]*?)\s*,\s*([^)]*?)\s*\)%/ + while(match = date_format_patt.exec(s)) { + if(match[1] == '' || match[2] == '') + s = s.replace(match[0], ''); + else + s = s.replace(match[0], util.date.formatted_date(match[1], match[2])); + } } catch(E) { dump(E+'\n'); } // Substrings -- 2.11.0