Bug 39944

Summary: Metadata should be trimmed before creating an ILL request
Product: Koha Reporter: Pedro Amorim <pedro.amorim>
Component: ILLAssignee: Pedro Amorim <pedro.amorim>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: pedro.amorim, tomascohen
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 39944: Add tests
Bug 39944: Trim form params
Bug 39944: Add tests
Bug 39944: Trim form params

Description Pedro Amorim 2025-05-20 12:27:15 UTC
When creating an ILL request, if the form data contains leading or trailing whitespaces, this may cause issues for backends.

Example:
A DOI is entered as ' 123', instead of '123'. If the backend needs to use that data entry, it'll need to first trim and/or sanitize it.
It's better if core Koha does this trimming before delegating the creation of the request to the backend, so it's maintained in a single place.
Comment 1 Pedro Amorim 2025-05-20 12:44:19 UTC Comment hidden (obsolete)
Comment 2 Pedro Amorim 2025-05-20 12:44:22 UTC Comment hidden (obsolete)
Comment 3 Pedro Amorim 2025-05-20 13:06:50 UTC
Created attachment 182672 [details] [review]
Bug 39944: Add tests

prove t/db_dependent/Koha/ILL/Request.t
Comment 4 Pedro Amorim 2025-05-20 13:06:54 UTC
Created attachment 182673 [details] [review]
Bug 39944: Trim form params

Test plan, ktd, before applying patch:
1) Enable ILLModule sys pref and create a new ILL request:
   <staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=Standard
2) Pick type 'journal article' and enter ' 123' to DOI (notice the leading white space)
3) Enter a cardnumber and a library. Click 'Create'.
4) Run the following SQL query (koha-mysql kohadev):
   $ SELECT * from illrequestattributes where illrequest_id = '<put your request ID here>' and type ='doi';
5) Notice the value is saved with the leading whitespace. Apply patch. Repeat. Notice it no longer saves with the leading white space.

Sponsored-by: NHS England