From 57976db4e0350e477627b55d27d6d44fc6e2b005 Mon Sep 17 00:00:00 2001 From: sunnavy Date: Tue, 28 Nov 2023 17:21:29 -0500 Subject: [PATCH] Escape one-time checkbox name in case it contains special regex characters This is to fix emails like foo+bar@example.com, previously its corresponding checkbox couldn't be checked because of the "+". --- share/html/Ticket/Update.html | 3 ++- share/static/js/util.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html index 6446e46042b..4601292f634 100644 --- a/share/html/Ticket/Update.html +++ b/share/html/Ticket/Update.html @@ -292,7 +292,8 @@ var unchecked = 0; jQuery('input:checkbox[name^=' + prefix + ']').each( function() { var name = jQuery(this).attr('name'); - name = name.replace(prefix + '-', ''); + name = escapeRegExp(name.replace(prefix + '-', '')); + var filter_function = function(n,i) { return n.match(new RegExp('^\\s*' + name + '\\s*$', 'i')) || n.match(new RegExp('<\\s*' + name + '\\s*>', 'i')); }; diff --git a/share/static/js/util.js b/share/static/js/util.js index d349bd6dcc9..a47f7db242b 100644 --- a/share/static/js/util.js +++ b/share/static/js/util.js @@ -677,6 +677,10 @@ function escapeCssSelector(str) { return str.replace(/([^A-Za-z0-9_-])/g,'\\$1'); } +function escapeRegExp(str) { + return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string +} + function createCookie(name,value,days) { var path = RT.Config.WebPath ? RT.Config.WebPath : "/";