Bug 40476 - Limit item type codes to letters and numbers
Summary: Limit item type codes to letters and numbers
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords: Academy
Depends on:
Blocks:
 
Reported: 2025-07-23 06:52 UTC by David Cook
Modified: 2025-07-23 15:32 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 40476: Limit item type codes to letters and numbers (1.90 KB, patch)
2025-07-23 06:55 UTC, David Cook
Details | Diff | Splinter Review

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