Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
verify user specified regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Brown committed Sep 25, 2016
1 parent bdbeff0 commit b26a80a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/CoreBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ function Botkit(configuration) {
} else {
return false;
}

}

this.cloneMessage = function(message) {
Expand Down Expand Up @@ -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];
}
Expand Down

0 comments on commit b26a80a

Please sign in to comment.