[Bug 44125] New: Serial claims CSV export breaks non-ASCII characters
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44125 Bug ID: 44125 Summary: Serial claims CSV export breaks non-ASCII characters Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Serials Assignee: koha-bugs@lists.koha-community.org Reporter: adolfo.rodriguez@xercode.es QA Contact: testopia@bugs.koha-community.org Target Milestone: --- The CSV file generated by "Download selected claims" on the serials claims page (serials/lateissues-export.pl) breaks every non-ASCII character. The script prints the rows to STDOUT without an encoding layer, so Perl writes one Latin-1 byte for each accented character instead of its UTF-8 sequence. The HTTP header does not help either: it is sent as "plain/text" (not a valid media type) and CGI adds the default "charset=ISO-8859-1". When the file is opened as UTF-8, the characters show as U+FFFD (e.g. "Año de la filosofÃa" becomes "A�o de la filosof�a"). This affects the data (title, issue number, vendor name) and the headers of CSV profiles with accented column names. Other CSV exports set binmode STDOUT, ':encoding(UTF-8)' before printing (e.g. tools/inventory.pl, reports/serials_stats.pl), but lateissues-export.pl never got it. To reproduce: 1. Create a vendor, and a subscription with that vendor for a record whose title has accented characters (e.g. "Año de la filosofÃa"). 2. Make one of its issues late (status Late, planned date in the past). 3. Go to Serials > Claims, choose the vendor, select the issue and click "Download selected claims". 4. Open the CSV as UTF-8: the accented characters are broken. -- 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=44125 Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |adolfo.rodriguez@xercode.es |ity.org | Status|NEW |Needs Signoff -- 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=44125 --- Comment #1 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- Created attachment 211735 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211735&action=edit Bug 44125: Encode the serial claims CSV export as UTF-8 serials/lateissues-export.pl printed the CSV without an encoding layer on STDOUT, so every non-ASCII character was written as a single Latin-1 byte. The header was sent as "plain/text", which is not a valid media type, and CGI added its default "charset=ISO-8859-1". Opened as UTF-8, the file showed U+FFFD instead of the accented characters, both in the data (title, issue number, vendor) and in the CSV profile headers. This patch sets binmode STDOUT to UTF-8 before printing, as other CSV exports do (tools/inventory.pl, reports/serials_stats.pl), and sends the file as text/csv with charset UTF-8. Steps to follow: 1. Create a vendor, and a subscription with that vendor for a record whose title has accented characters, e.g. "Año de la filosofía". 2. Make one of its issues late (status Late, planned date in the past), with an accented issue number, e.g. "Año 1, núm. 2". 3. Optional: create a CSV profile of type "Late issues" with accented headers, e.g. Título=title|Número=serialseq|Proveedor=name 4. Go to Serials > Claims, choose the vendor, select the issue, choose the CSV profile and click "Download selected claims". 5. Open the CSV as UTF-8: the accented characters show as "�" (e.g. "A�o de la filosof�a"). 6. Apply this patch and restart services. 7. Repeat step 4 and open the new CSV: the accented characters are correct, in the data and in the headers. 8. Check that the response is sent as "text/csv; charset=UTF-8" (e.g. in the browser developer tools, Network tab). Signed-off-by: Adolfo Rodríguez <adolfo.rodriguez@xercode.es> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44125 Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=41628 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44125 --- Comment #2 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- The export now sets binmode STDOUT to UTF-8 before printing, like the other CSV exports, and sends the file as text/csv with charset UTF-8. Before, the type was "plain/text", which is not a valid media type, and CGI added its default ISO-8859-1 charset. The test plan is in the commit message. Test data: a vendor, a subscription for a record titled "Año de la filosofía" with a late issue "Año 1, núm. 2", and optionally a "Late issues" CSV profile with accented headers. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44125 Michael Mundet <michael.mundet@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211735|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=44125 --- Comment #3 from Michael Mundet <michael.mundet@gmail.com> --- Created attachment 212010 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212010&action=edit Bug 44125: Encode the serial claims CSV export as UTF-8 serials/lateissues-export.pl printed the CSV without an encoding layer on STDOUT, so every non-ASCII character was written as a single Latin-1 byte. The header was sent as "plain/text", which is not a valid media type, and CGI added its default "charset=ISO-8859-1". Opened as UTF-8, the file showed U+FFFD instead of the accented characters, both in the data (title, issue number, vendor) and in the CSV profile headers. This patch sets binmode STDOUT to UTF-8 before printing, as other CSV exports do (tools/inventory.pl, reports/serials_stats.pl), and sends the file as text/csv with charset UTF-8. Steps to follow: 1. Create a vendor, and a subscription with that vendor for a record whose title has accented characters, e.g. "Año de la filosofía". 2. Make one of its issues late (status Late, planned date in the past), with an accented issue number, e.g. "Año 1, núm. 2". 3. Optional: create a CSV profile of type "Late issues" with accented headers, e.g. Título=title|Número=serialseq|Proveedor=name 4. Go to Serials > Claims, choose the vendor, select the issue, choose the CSV profile and click "Download selected claims". 5. Open the CSV as UTF-8: the accented characters show as "�" (e.g. "A�o de la filosof�a"). 6. Apply this patch and restart services. 7. Repeat step 4 and open the new CSV: the accented characters are correct, in the data and in the headers. 8. Check that the response is sent as "text/csv; charset=UTF-8" (e.g. in the browser developer tools, Network tab). Signed-off-by: Adolfo Rodríguez <adolfo.rodriguez@xercode.es> Signed-off-by: Michael Mundet <michael.mundet@gmail.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44125 Michael Mundet <michael.mundet@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off --- Comment #4 from Michael Mundet <michael.mundet@gmail.com> --- Signed off using a sandbox -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44125 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |emily.lamancusa@montgomeryc |y.org |ountymd.gov -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44125 Emily Lamancusa (emlam) <emily.lamancusa@montgomerycountymd.gov> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #212010|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=44125 --- Comment #5 from Emily Lamancusa (emlam) <emily.lamancusa@montgomerycountymd.gov> --- Created attachment 212321 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212321&action=edit Bug 44125: Encode the serial claims CSV export as UTF-8 serials/lateissues-export.pl printed the CSV without an encoding layer on STDOUT, so every non-ASCII character was written as a single Latin-1 byte. The header was sent as "plain/text", which is not a valid media type, and CGI added its default "charset=ISO-8859-1". Opened as UTF-8, the file showed U+FFFD instead of the accented characters, both in the data (title, issue number, vendor) and in the CSV profile headers. This patch sets binmode STDOUT to UTF-8 before printing, as other CSV exports do (tools/inventory.pl, reports/serials_stats.pl), and sends the file as text/csv with charset UTF-8. Steps to follow: 1. Create a vendor, and a subscription with that vendor for a record whose title has accented characters, e.g. "Año de la filosofía". 2. Make one of its issues late (status Late, planned date in the past), with an accented issue number, e.g. "Año 1, núm. 2". 3. Optional: create a CSV profile of type "Late issues" with accented headers, e.g. Título=title|Número=serialseq|Proveedor=name 4. Go to Serials > Claims, choose the vendor, select the issue, choose the CSV profile and click "Download selected claims". 5. Open the CSV as UTF-8: the accented characters show as "�" (e.g. "A�o de la filosof�a"). 6. Apply this patch and restart services. 7. Repeat step 4 and open the new CSV: the accented characters are correct, in the data and in the headers. 8. Check that the response is sent as "text/csv; charset=UTF-8" (e.g. in the browser developer tools, Network tab). Signed-off-by: Adolfo Rodríguez <adolfo.rodriguez@xercode.es> Signed-off-by: Michael Mundet <michael.mundet@gmail.com> Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44125 Emily Lamancusa (emlam) <emily.lamancusa@montgomerycountymd.gov> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org