Receipt Template Non-String Protection
authorThomas Berezansky <tsbere@mvlc.org>
Mon, 19 Dec 2011 20:55:52 +0000 (15:55 -0500)
committerJason Etheridge <jason@esilibrary.com>
Wed, 11 Jan 2012 05:02:30 +0000 (00:02 -0500)
Don't try to replace on things that aren't strings.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/xul/staff_client/chrome/content/util/print.js

index 414c8d7..166b486 100644 (file)
@@ -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,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
     },
 
@@ -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 */