Better handling of undefined values in receipts
authorJeff Godin <jgodin@tadl.org>
Mon, 10 Oct 2011 20:18:49 +0000 (16:18 -0400)
committerJeff Godin <jgodin@tadl.org>
Mon, 10 Oct 2011 20:18:49 +0000 (16:18 -0400)
Teach escape_html to return an empty string when given an
undefined value as input.

Previously: a macro being replaced with an undefined value
resulted in the macro itself remaining in the output.

Now: a macro being replaced with an undefined value will result
in an empty string in the output.

Open-ILS/xul/staff_client/chrome/content/util/print.js

index 49fa358..bb3b611 100644 (file)
@@ -96,7 +96,11 @@ util.print.prototype = {
     },
 
     'escape_html' : function(data) {
-        return data.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
+        if (data) {
+            return data.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
+        } else {
+            return '';
+        }
     },
 
     'simple' : function(msg,params) {