Bug 40476

Summary: Limit new item type codes to letters and numbers
Product: Koha Reporter: David Cook <dcook>
Component: CatalogingAssignee: David Cook <dcook>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: esther.melander, m.de.rooy
Version: MainKeywords: Academy
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 40476: Limit item type codes to letters and numbers

Description David Cook 2025-07-23 06:52:05 UTC
Item type codes should be limited to letters and numbers.

When you have item type codes with punctuation in them, it can lead to unexpected search result hits. For instance, if you have items with "BOOK" and "E-BOOK", searches for "E-BOOK" will return hits for "BOOK".
Comment 1 David Cook 2025-07-23 06:52:22 UTC
I suspect there are (many) duplicates of this bug but I haven't been able to find them yet.
Comment 2 David Cook 2025-07-23 06:55:13 UTC
Created attachment 184531 [details] [review]
Bug 40476: Limit item type codes to letters and numbers

This patch adds a custom jquery validator method to perform a regex
test on item type codes in the admin module.

Test plan:
0. Apply the patch
1. Go to http://localhost:8081/cgi-bin/koha/admin/itemtypes.pl?op=add_form
2. Try to input an "Item type" like "abc123+
3. Note the input turns red and the message "Invalid pattern" appears.
4. Try to input an "Item type" like "ébook"
5. Note that the input is capitalised, it stays black, and there is no warning
6. Try out more combinations of things you'd like to use as item type codes
Comment 3 Esther Melander 2025-07-23 15:32:44 UTC
Tested and works as described.

Signed-off-by: Esther Melander <esther@bywatersolutions.com>