Bug 39944 - Metadata should be trimmed before creating an ILL request
Summary: Metadata should be trimmed before creating an ILL request
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: ILL (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Pedro Amorim
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-20 12:27 UTC by Pedro Amorim
Modified: 2025-05-20 13:06 UTC (History)
2 users (show)

See Also:
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 (1.70 KB, patch)
2025-05-20 12:44 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 39944: Trim form params (2.09 KB, patch)
2025-05-20 12:44 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 39944: Add tests (1.70 KB, patch)
2025-05-20 13:06 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 39944: Trim form params (2.19 KB, patch)
2025-05-20 13:06 UTC, Pedro Amorim
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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