From: pines Date: Wed, 28 Mar 2007 14:38:00 +0000 (+0000) Subject: escape characters that would mess up HTML with label printing. Is there a better... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8f7c201b9e2f3a2be950cf9096805085df07039f;p=Evergreen.git escape characters that would mess up HTML with label printing. Is there a better way to do this? encode, urlencode, etc? git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0_4@7114 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/chrome/content/util/text.js b/Open-ILS/xul/staff_client/chrome/content/util/text.js index 9d5ce34717..ce9f029485 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/text.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/text.js @@ -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(/&/,'&'); + text = text.replace(/ /,' '); + text = text.replace(//,'>'); + return text; +} + dump('exiting util/text.js\n'); diff --git a/Open-ILS/xul/staff_client/server/cat/spine_labels.js b/Open-ILS/xul/staff_client/server/cat/spine_labels.js index ed4fb8cf3e..d158277660 100644 --- a/Open-ILS/xul/staff_client/server/cat/spine_labels.js +++ b/Open-ILS/xul/staff_client/server/cat/spine_labels.js @@ -245,13 +245,13 @@ 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';