From 2e80fde8c4ffdc9924db3baf59520282a8a83169 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Mon, 19 Dec 2011 15:55:52 -0500 Subject: [PATCH] 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 --- Open-ILS/xul/staff_client/chrome/content/util/print.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 */ -- 2.11.0