escape characters that would mess up HTML with label printing. Is there a better...
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 Mar 2007 14:38:00 +0000 (14:38 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 Mar 2007 14:38:00 +0000 (14:38 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0_4@7114 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/util/text.js
Open-ILS/xul/staff_client/server/cat/spine_labels.js

index 9d5ce34..ce9f029 100644 (file)
@@ -4,7 +4,7 @@ if (typeof util == 'undefined') var util = {};
 util.text = {};
 
 util.text.EXPORT_OK    = [ 
-       'wrap_on_space',
+       'wrap_on_space', 'html_escape',
 ];
 util.text.EXPORT_TAGS  = { ':all' : util.text.EXPORT_OK };
 
@@ -25,4 +25,12 @@ util.text.wrap_on_space = function( text, length ) {
        }
 }
 
+util.text.html_escape = function( text ) {
+       text = text.replace(/&/,'&amp;');
+       text = text.replace(/ /,'&nbsp;');
+       text = text.replace(/</,'&lt;');
+       text = text.replace(/>/,'&gt;');
+       return text;
+}
+
 dump('exiting util/text.js\n');
index ed4fb8c..d158277 100644 (file)
                                                        var nl2 = gb.getElementsByAttribute('name','spine');
                                                        for (var k = 0; k < nl2.length; k++) {
                                                                for (var m = 0; m < lm; m++) html += ' ';
-                                                               html += expand_macros( nl2[k].value, copy, volume, volume.record() ).substr(0,lw);
+                                                               html += util.text.html_escape(expand_macros( nl2[k].value, copy, volume, volume.record() ).substr(0,lw));
                                                                if ($('pl').checked) {
                                                                        var sib = nl2[k].nextSibling;
                                                                        if (sib) {
                                                                                for (var m = 0; m < lw - nl2[k].value.length; m++) html += ' ';
                                                                                for (var m = 0; m < mm; m++) html += ' ';
-                                                                               html += expand_macros( sib.value, copy, volume, volume.record() ).substr(0,plw);
+                                                                               html += util.text.html_escape(expand_macros( sib.value, copy, volume, volume.record() ).substr(0,plw));
                                                                        }
                                                                }
                                                                html += '\n';