Bug 37606

Summary: Framework export module should escape double quotes
Product: Koha Reporter: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Component: System AdministrationAssignee: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Status: Pushed to main --- QA Contact: Chris Cormack <chris>
Severity: normal    
Priority: P5 - low CC: gmcharlt, martin.renvoize, sukhmandeep.benipal
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00
Circulation function:
Attachments: Bug 37606 - Fix framework export module to replace double quotes with simple quotes
Bug 37606 - Fix framework export module to escape double quotes
Bug 37606 - Fix framework export module to escape double quotes
Bug 37606 - Fix framework export module to escape double quotes
Bug 37606: Fix framework export module to escape double quotes

Description Baptiste Wojtkowski (bwoj) 2024-08-09 14:46:07 UTC
When exporting as csv, the exporter does not check the presence of double quote in the fields. Hence, if there is one double quote, the csv is broken.
Comment 1 Baptiste Wojtkowski (bwoj) 2024-08-09 14:52:56 UTC Comment hidden (obsolete)
Comment 2 Baptiste Wojtkowski (bwoj) 2024-08-09 15:02:33 UTC
Created attachment 170200 [details] [review]
Bug 37606 - Fix framework export module to escape double quotes

When exporting a framework as csv, the exporter does not check the presence of double quote in the fields. Hence, if there is one double quote, the csv is broken.

TEST PLAN:
1 - Change a framework to add a field containing double quote in name
2 - Export it in csv
3 - Create a new framework
4 - Import the csv in the new framework -> every fields after the one
containing double quotes should have no subfields
5 - APPLY PATCH
6 - Repeat 2-5 -> everything should be correctly exported
Comment 3 Baptiste Wojtkowski (bwoj) 2024-08-09 15:06:24 UTC
NOTE: CSV exports should all use the same lib, I'll try and fix it once I have some time
Comment 4 Sukhmandeep 2024-09-10 18:16:49 UTC
Hi Baptiste,

I'm having some trouble following the test plan. Could you break down the steps a bit more? Also, which framework are we referring to? I'm guessing the MARC bibliographic framework, but I'm not sure.

Thanks!
Comment 5 Baptiste Wojtkowski (bwoj) 2024-09-11 08:27:32 UTC
Hi !
Thanks for paying attention to this patch ! :)

For the 1, go in Administration -> MARC bibliographic frameworks, pick any framework by clicking action->marc structure (default framework is fine) and in a field of your choice, add double quotes (check that there are fields with subfields after the modified one by clicking on action->view subfields).

Then you go back to the framework list for the 2, click on actions-> export-> csv

3 - click on new framework and fill in the form

4 - on the created framework, click on actions -> import, and pick the generated csv. Then, check the imported framework, the last fields will have no subfields.
Comment 6 Sukhmandeep 2024-09-11 14:54:51 UTC
I tried to recreate the issue, but the results I obtained do not match those described in the test plan.

For the step:

4 - Import the CSV in the new framework
Expected Behavior: Every field after the one containing double quotes should have no subfields.

Observed Results:

- All the fields after the one containing double quotes, including the field with the double quotes, were not present in the new framework.

- The fields before the one with the double quotes had no subfields.

After applying the patch, everything seems to be working correctly. All fields are now present with their appropriate subfields.

Note: I am not sure if the issue can be signed off.
Comment 7 Baptiste Wojtkowski (bwoj) 2024-09-11 15:29:03 UTC
Oh yes sorry, I described the behaviour if you modify a subfield to add a double quote.
It is due to the way it is imported. It imports every fields then every subfields. If you break the field, it will break every field after and every subfield.
If you break a subfield, it will break every subfield after.
Comment 8 Baptiste Wojtkowski (bwoj) 2024-09-11 15:33:46 UTC
Created attachment 171343 [details] [review]
Bug 37606 - Fix framework export module to escape double quotes

When exporting a framework as csv, the exporter does not check the presence of double quote in the fields. Hence, if there is one double quote, the csv is broken.

TEST PLAN:
1 - Change a framework to add a field containing double quote in name
2 - Export it in csv
3 - Create a new framework
4 - Import the csv in the new framework -> every fields after the one
containing double quotes should be broke. Every other fields should have
no subfield
5 - APPLY PATCH
6 - Repeat 2-5 -> everything should be correctly exported
Comment 9 Sukhmandeep 2024-09-11 15:50:12 UTC
Created attachment 171344 [details] [review]
Bug 37606 - Fix framework export module to escape double quotes

When exporting a framework as csv, the exporter does not check the presence of double quote in the fields. Hence, if there is one double quote, the csv is broken.

TEST PLAN:
1 - Change a framework to add a field containing double quote in name
2 - Export it in csv
3 - Create a new framework
4 - Import the csv in the new framework -> every fields after the one
containing double quotes should be broke. Every other fields should have
no subfield
5 - APPLY PATCH
6 - Repeat 2-5 -> everything should be correctly exported

Signed-off-by: Sukhmandeep Benipal <sukhmandeep.benipal@inLibro.com>
Comment 10 Chris Cormack 2024-10-17 22:33:58 UTC
Created attachment 172934 [details] [review]
Bug 37606: Fix framework export module to escape double quotes

When exporting a framework as csv, the exporter does not check the presence of double quote in the fields. Hence, if there is one double quote, the csv is broken.

TEST PLAN:
1 - Change a framework to add a field containing double quote in name
2 - Export it in csv
3 - Create a new framework
4 - Import the csv in the new framework -> every fields after the one
containing double quotes should be broke. Every other fields should have
no subfield
5 - APPLY PATCH
6 - Repeat 2-5 -> everything should be correctly exported

Signed-off-by: Sukhmandeep Benipal <sukhmandeep.benipal@inLibro.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Comment 11 Katrin Fischer 2024-10-18 12:27:21 UTC
Pushed for 24.11!

Well done everyone, thank you!