[Bug 44218] New: unimarc_field_4XX.pl copies HTML entities (& " ') into 4XX subfields
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44218 Bug ID: 44218 Summary: unimarc_field_4XX.pl copies HTML entities (& " ') into 4XX subfields Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Cataloging Assignee: koha-bugs@lists.koha-community.org Reporter: f.demians@tamil.fr QA Contact: testopia@bugs.koha-community.org CC: m.de.rooy@rijksmuseum.nl Target Milestone: --- When cataloguing a UNIMARC record, the 4XX linking plugin (unimarc_field_4XX.pl) copies some subfields of the linked record (200$a, 200$e, 200$f, 210$c, etc.) into the 4XX field being edited (461, 463, 410...). If these values contain an ampersand or a double quote, they are copied as HTML entities (&, ") and saved as-is in the record. On some systems (for instance Ubuntu 22.04, whose Template Toolkit package also escapes apostrophes in the html filter), every apostrophe is copied as ' too, so most titles in French, Italian, English... are corrupted. Example: linking a record to a record titled L'Adattamento umano all'ambiente passato e presente fills 463$t with L'Adattamento umano all'ambiente passato e presente On one production catalogue, about 1,900 records were found with such entities in their 4XX fields. Cause: in unimarc_field_4XX.tt, values are injected into JavaScript with: subfield.value = "[% To.json( subfield_value_t ) | html %]"; To.json already escapes the value for a JavaScript string; the extra html filter should not be there ($raw is used everywhere else with To.json inside a script). To reproduce: 1. Use a UNIMARC installation. 2. Create a record A whose title (200$a) is: L'art "roman" & gothique 3. Create a new record B and link it to A in 463 using the 4XX plugin. 4. Look at 463$t in record B: it contains & and " (and ' on some systems) instead of the original characters. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44218 Frédéric Demians <f.demians@tamil.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |f.demians@tamil.fr |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44218 --- Comment #1 from Frédéric Demians <f.demians@tamil.fr> --- Created attachment 212297 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212297&action=edit Bug 44218: Add tests This patch adds a test that renders the UNIMARC 4XX cataloguing plugin template in 'fillinput' mode and checks that the values copied from the linked record are not HTML-escaped inside the generated JavaScript. Test plan: 1. prove t/db_dependent/cataloguing/value_builder/unimarc_field_4XX.t => FAIL: double quotes and ampersands are turned into " and & -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44218 --- Comment #2 from Frédéric Demians <f.demians@tamil.fr> --- Created attachment 212298 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212298&action=edit Bug 44218: Do not HTML-escape values copied by unimarc_field_4XX.pl When a UNIMARC record is linked to another record with the 4XX cataloguing plugin (unimarc_field_4XX.pl), some subfields of the linked record (200$a, 200$e, 200$f, 210$c, etc.) are copied into the 4XX field being edited. The template injects these values into a JavaScript string with: subfield.value = "[% To.json( subfield_value_t ) | html %]"; To.json already escapes the value for a JavaScript string. The extra html filter turns & into & and " into ", and those entities are copied as-is into the subfield and saved in the record. On some distributions (for instance Ubuntu 22.04) the html filter of Template Toolkit also turns ' into ', so every title with an apostrophe is corrupted too. This patch uses the $raw filter instead, as is done everywhere else To.json is used inside a script. Test plan: 1. Use a UNIMARC installation. 2. Create or edit a record A whose title (200$a) is: L'art "roman" & gothique 3. Create a new record B and link it to A in 463 using the 4XX plugin (click the "..." of 463, search for A, click "Choose"). 4. Look at 463$t in record B => It contains & and " (and ' on some systems) 5. Apply the patch. 6. Repeat 3. => 463$t contains exactly: L'art "roman" & gothique 7. prove t/db_dependent/cataloguing/value_builder/unimarc_field_4XX.t => PASS -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44218 Frédéric Demians <f.demians@tamil.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44218 Community Sandboxes <sandboxes@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #212297|0 |1 is obsolete| | Attachment #212298|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44218 --- Comment #3 from Community Sandboxes <sandboxes@biblibre.com> --- Created attachment 212487 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212487&action=edit Bug 44218: Add tests This patch adds a test that renders the UNIMARC 4XX cataloguing plugin template in 'fillinput' mode and checks that the values copied from the linked record are not HTML-escaped inside the generated JavaScript. Test plan: 1. prove t/db_dependent/cataloguing/value_builder/unimarc_field_4XX.t => FAIL: double quotes and ampersands are turned into " and & Signed-off-by: Mathieu Saby <mathsabypro@gmail.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44218 --- Comment #4 from Community Sandboxes <sandboxes@biblibre.com> --- Created attachment 212488 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212488&action=edit Bug 44218: Do not HTML-escape values copied by unimarc_field_4XX.pl When a UNIMARC record is linked to another record with the 4XX cataloguing plugin (unimarc_field_4XX.pl), some subfields of the linked record (200$a, 200$e, 200$f, 210$c, etc.) are copied into the 4XX field being edited. The template injects these values into a JavaScript string with: subfield.value = "[% To.json( subfield_value_t ) | html %]"; To.json already escapes the value for a JavaScript string. The extra html filter turns & into & and " into ", and those entities are copied as-is into the subfield and saved in the record. On some distributions (for instance Ubuntu 22.04) the html filter of Template Toolkit also turns ' into ', so every title with an apostrophe is corrupted too. This patch uses the $raw filter instead, as is done everywhere else To.json is used inside a script. Test plan: 1. Use a UNIMARC installation. 2. Create or edit a record A whose title (200$a) is: L'art "roman" & gothique 3. Create a new record B and link it to A in 463 using the 4XX plugin (click the "..." of 463, search for A, click "Choose"). 4. Look at 463$t in record B => It contains & and " (and ' on some systems) 5. Apply the patch. 6. Repeat 3. => 463$t contains exactly: L'art "roman" & gothique 7. prove t/db_dependent/cataloguing/value_builder/unimarc_field_4XX.t => PASS Signed-off-by: Mathieu Saby <mathsabypro@gmail.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44218 Community Sandboxes <sandboxes@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off --- Comment #5 from Community Sandboxes <sandboxes@biblibre.com> --- Signed off using a sandbox -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org