Bugzilla – Attachment 184531 Details for
Bug 40476
Limit new item type codes to letters and numbers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40476: Limit item type codes to letters and numbers
Bug-40476-Limit-item-type-codes-to-letters-and-num.patch (text/plain), 1.90 KB, created by
David Cook
on 2025-07-23 06:55:13 UTC
(
hide
)
Description:
Bug 40476: Limit item type codes to letters and numbers
Filename:
MIME Type:
Creator:
David Cook
Created:
2025-07-23 06:55:13 UTC
Size:
1.90 KB
patch
obsolete
>From 6630861e2ba0dcddd26375055491c0511d6da81b Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Wed, 23 Jul 2025 06:52:30 +0000 >Subject: [PATCH] Bug 40476: Limit item type codes to letters and numbers >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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 >--- > koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >index 0f7915e365..a2dc1279c4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >@@ -551,9 +551,13 @@ > ); > }); > >+ jQuery.validator.addMethod("regex", function(value, element, regex){ >+ return this.optional(element) || new RegExp(regex).test(value); >+ }, _("Invalid pattern") ); >+ > $( "#itemtypeentry" ).validate({ > rules: { >- itemtype: { required: true }, >+ itemtype: { required: true, regex: /^[\p{L}\p{N}]+$/u }, //Allow only Unicode letters and numbers > description: { required: true }, > rentalcharge: { number: true }, > rentalcharge_hourly: { number: true }, >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40476
: 184531