TPAC: Escape single quotes in MFHD record location
authorDan Scott <dscott@laurentian.ca>
Thu, 6 Sep 2012 16:25:01 +0000 (12:25 -0400)
committerDan Wells <dbw2@calvin.edu>
Fri, 7 Sep 2012 18:03:46 +0000 (14:03 -0400)
If an MFHD record contains an 852 field with a subfield containing a
single quote, the unescaped single quote is introduced directly into the
value of the JavaScript hash that uses single quotes as delimiters -
thereby generating a JS exception and preventing the staff client from
properly populating the MFHD Editor menu.

This commit escapes incoming single quotes from the MFHD location field
to prevent that from happening. The other fields in the JS hash are
numeric and therefore should not need escaping.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>

Open-ILS/src/templates/opac/parts/js.tt2

index b4a775d..d6cacbe 100644 (file)
@@ -23,7 +23,7 @@
                 [% FOR summary IN ctx.mfhd_summaries %]
                 {
                     'id' : '[% summary.sre_id %]', 
-                    'label' : '[% summary.location %]',
+                    'label' : '[% summary.location | replace("'", "\\'") %]',
                     'entryNum' : '[% loop.index %]',
                     'owning_lib' : '[% summary.owning_lib %]'
                 },