From: Thomas Berezansky Date: Mon, 19 Dec 2011 20:55:52 +0000 (-0500) Subject: Receipt Template Non-String Protection X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2e80fde8c4ffdc9924db3baf59520282a8a83169;p=evergreen%2Fmasslnc.git Receipt Template Non-String Protection Don't try to replace on things that aren't strings. Signed-off-by: Thomas Berezansky Signed-off-by: Jason Etheridge --- 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 414c8d762e..166b4867f6 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/print.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js @@ -108,6 +108,7 @@ util.print.prototype = { 'escape_html' : function(data) { if (typeof data == 'object') { return ''; } + if (typeof data != 'string') { return data; } return data.replace(/&/g,'&').replace(//g,'>'); }, @@ -406,7 +407,7 @@ util.print.prototype = { for (var i in params.data) { var re = new RegExp('%'+i+'%',"g"); if (typeof params.data[i] == 'string' || typeof params.data[i] == 'number') { - try{b = s; s=s.replace(re, (typeof params.data[i] == 'string' ? this.escape_html(params.data[i]) : params.data[i]));} + try{b = s; s=s.replace(re, this.escape_html(params.data[i]));} catch(E){s = b; this.error.standard_unexpected_error_alert('print.js, template_sub(): 3 string = <' + s + '>',E);} } else { /* likely a null, print as an empty string */