From b26a80a2797548811088a78cd77ae12db6bae514 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Sun, 25 Sep 2016 13:41:29 -0500 Subject: [PATCH] verify user specified regexp --- lib/CoreBot.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/CoreBot.js b/lib/CoreBot.js index a3f5ab9c7..382ea7756 100755 --- a/lib/CoreBot.js +++ b/lib/CoreBot.js @@ -452,7 +452,7 @@ function Botkit(configuration) { } else { return false; } - + } this.cloneMessage = function(message) { @@ -790,9 +790,17 @@ function Botkit(configuration) { // the pattern might be a string to match (including regular expression syntax) // or it might be a prebuilt regular expression - var test; + var test = null; if (typeof(tests[t]) == 'string') { - test = new RegExp(tests[t], 'i'); + try { + test = new RegExp(tests[t], 'i'); + } catch(err) { + botkit.log('Error in regular expression: ' + tests[t] + ': ' + err); + return false; + } + if (!test) { + return false; + } } else { test = tests[t]; }