From bbff7403fbf46f9ad92240ac213df8d30ef31b64 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 20 Sep 2018 02:56:13 +0200 Subject: update packages --- node_modules/regex-not/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'node_modules/regex-not/index.js') diff --git a/node_modules/regex-not/index.js b/node_modules/regex-not/index.js index 8593d8b3a..02bfed4a8 100644 --- a/node_modules/regex-not/index.js +++ b/node_modules/regex-not/index.js @@ -1,6 +1,7 @@ 'use strict'; var extend = require('extend-shallow'); +var safe = require('safe-regex'); /** * The main export is a function that takes a `pattern` string and an `options` object. @@ -41,7 +42,7 @@ toRegex.create = function(pattern, options) { } var opts = extend({}, options); - if (opts && opts.contains === true) { + if (opts.contains === true) { opts.strictNegate = false; } @@ -50,13 +51,18 @@ toRegex.create = function(pattern, options) { var endChar = opts.endChar ? opts.endChar : '+'; var str = pattern; - if (opts && opts.strictNegate === false) { + if (opts.strictNegate === false) { str = '(?:(?!(?:' + pattern + ')).)' + endChar; } else { str = '(?:(?!^(?:' + pattern + ')$).)' + endChar; } - return open + str + close; + var res = open + str + close; + if (opts.safe === true && safe(res) === false) { + throw new Error('potentially unsafe regular expression: ' + res); + } + + return res; }; /** -- cgit v1.2.3