Bugzilla – Attachment 191373 Details for
Bug 15349
Problem with email pattern check on forms
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15349: Accept email addresses with display name in system preferences
Bug-15349-Accept-email-addresses-with-display-name.patch (text/plain), 3.90 KB, created by
Ayoub Glizi-Vicioso
on 2026-01-13 16:59:02 UTC
(
hide
)
Description:
Bug 15349: Accept email addresses with display name in system preferences
Filename:
MIME Type:
Creator:
Ayoub Glizi-Vicioso
Created:
2026-01-13 16:59:02 UTC
Size:
3.90 KB
patch
obsolete
>From c180ddcaec26c5b27830f92140e2bf4525e31f8f Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Tue, 13 Jan 2026 15:15:34 +0200 >Subject: [PATCH] Bug 15349: Accept email addresses with display name in system > preferences > >To test: >1. Before applying this patch, navigate to system preferences >2. Search for preference KohaAdminEmailAddress >3. Enter anything that is not in the format of valid "email@address.com" >4. Observe error "Please enter a valid email address." >5. Apply patch >6. Enter anything that is not in the format of valid "email@address.com" > and not in the format of "display name <email@address.com>" >7. Observe error "Please enter a valid email address (display name allowed)." >8. Enter email@address.com >9. Save all Administration preferences >10. Observe no errors >11. Enter Display Name <email@address.com> >12. Save all Administration preferences >13. Observe no errors > >Signed-off-by: Ayoub Glizi-Vicioso <ayoub.glizi-vicioso@inLibro.com> >--- > .../en/modules/admin/preferences/admin.pref | 2 +- > .../prog/js/pages/preferences.js | 6 ++++++ > .../intranet-tmpl/prog/js/staff-global.js | 19 +++++++++++++++++++ > 3 files changed, 26 insertions(+), 1 deletion(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >index eac9b14907..51b1302172 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >@@ -4,7 +4,7 @@ Administration: > - > - "Email address for the administrator of Koha: " > - pref: KohaAdminEmailAddress >- class: email >+ class: email-with-display-name > - "(This is the default From: address for emails unless there is one for the particular library, and is referred to when an internal error occurs.)" > - > - "Email address to be set as the replyto in emails: " >diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >index bbe128f249..2cf6419fcb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >@@ -371,6 +371,12 @@ $(".preference-email").each(function () { > }); > }); > >+$(".preference-email-with-display-name").each(function () { >+ $(this).rules("add", { >+ email_with_display_name: true, >+ }); >+}); >+ > $(".modalselect").on("click", function () { > var datasource = $(this).data("source"); > var exclusions = $(this).data("exclusions").split("|"); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 3e8f312d27..e5b90de5ff 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -188,6 +188,25 @@ $(document).ready(function () { > decimal_rate: true, > }); > >+ jQuery.validator.addMethod( >+ "email_with_display_name", >+ function (value, element) { >+ // https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address >+ let html5_email_regex = >+ "[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*"; >+ let display_name_regex = "[^<>\x0A\x0D]+"; >+ let validation_regex = new RegExp( >+ `^${display_name_regex}<${html5_email_regex}>\$|^${html5_email_regex}\$` >+ ); >+ return this.optional(element) || validation_regex.test(value); >+ }, >+ __("Please enter a valid email address (display name allowed).") >+ ); >+ >+ jQuery.validator.addClassRules("email_with_display_name", { >+ email_with_display_name: true, >+ }); >+ > $("#logout").on("click", function () { > logOut(); > }); >-- >2.52.0
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 15349
:
191349
|
191366
| 191373