As the title, if a z39.50 target has an apostrophe in the name, the editor fails with an "Unexpected token" Javascript error. The array containing the targets is constructed then embedded in the page template and, since the string is enclosed in unescaped single apostrophes, things fall over. The fix is to replace ' in target names with '
Created attachment 84566 [details] [review] Bug 22243: Fix unescaped apostrophe in Z target This patch escapes apostrophes in the z39.50 target name prior to them being embedded in the template. To test: - Create a z39.50 target containing an apostrophe in the title - Note that the Advanced Cataloguer editor does not load - Apply the patch - TEST: Note that the Advanced Cataloguer editor does load
This patch doesn't work for me. What about doing this? name: '[% server.servername | html_entity %]', It looks like the html_entity filter is what we want here: http://template-toolkit.org/docs/manual/Filters.html#section_html_entity
Created attachment 114499 [details] [review] Bug 22243: Fix unescaped apostrophe in Z target This patch escapes apostrophes in the z39.50 target name prior to them being embedded in the template. To test: - Create a z39.50 target containing an apostrophe in the title - Note that the Advanced Cataloguer editor does not load - Apply the patch - TEST: Note that the Advanced Cataloguer editor does load
Created attachment 114502 [details] [review] Bug 22243: Fix unescaped apostrophe in Z target This patch escapes apostrophes in the z39.50 target name prior to them being embedded in the template. To test: - Create a z39.50 target containing an apostrophe in the title - Note that the Advanced Cataloguer editor does not load - Apply the patch - TEST: Note that the Advanced Cataloguer editor does load Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Created attachment 114561 [details] [review] Bug 22243: Fix unescaped apostrophe in Z target This patch escapes apostrophes in the z39.50 target name prior to them being embedded in the template. To test: - Create a z39.50 target containing an apostrophe in the title - Note that the Advanced Cataloguer editor does not load - Apply the patch - TEST: Note that the Advanced Cataloguer editor does load Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Pushed to master for 21.05, thanks to everybody involved!
Not sure this was the best way to fix. There are only a few places with 'html_entity' filter. Other places use double-quotes for JS strings and html TT filter replaces double-quotes with "
Pushed to 20.11.x for 20.11.01
Pushed to 20.05.x for 20.05.07
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.