summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-05-08 09:42:17 +0200
committerAleksander Machniak <alec@alec.pl>2013-05-08 09:42:17 +0200
commitdffdd168aebfc5f67bf61baee9739b5bf96b5e50 (patch)
tree95c89d443ee28f4a0c6669f22a637025e6f7b47a
parent864745bc9a14afaee640f9960e16ccdbc57e237d (diff)
Improved regexp
-rwxr-xr-xplugins/attachment_reminder/attachment_reminder.js11
1 files changed, 4 insertions, 7 deletions
diff --git a/plugins/attachment_reminder/attachment_reminder.js b/plugins/attachment_reminder/attachment_reminder.js
index 01f2b4993..a4f3e6325 100755
--- a/plugins/attachment_reminder/attachment_reminder.js
+++ b/plugins/attachment_reminder/attachment_reminder.js
@@ -18,15 +18,12 @@ function rcmail_get_compose_message()
function rcmail_check_message(msg)
{
- var i, rg, keywords = rcmail.gettext('keywords', 'attachment_reminder').split(",").concat([".doc", ".pdf"]);
+ var i, rx, keywords = rcmail.gettext('keywords', 'attachment_reminder').split(",").concat([".doc", ".pdf"]);
- for (i=0; i<keywords.length; i++) {
- rg = new RegExp(keywords[i],'i');
- if (msg.search(rg) != -1)
- return true;
- }
+ $.each(keywords, function(n) { return RegExp.escape(n); });
+ rx = new RegExp('(' + keywords.join('|') + ')', 'i');
- return false;
+ return msg.search(rx) != -1;
}
function rcmail_have_attachments()