Check if patterns are valid regular expressions

main
q-- 9 years ago
parent f328f22cf4
commit 766bf4df7f

@ -27,6 +27,11 @@ for ( app in json.apps ) {
attrs = pattern.split('\\;'), attrs = pattern.split('\\;'),
regex = '/' + attrs.shift().replace('/', '\/') + '/'; regex = '/' + attrs.shift().replace('/', '\/') + '/';
//Check if the pattern is a valid RegExp
//Note: unlike when used in Wappalyzer, the modifier i isn't added here
new RegExp(regex);
if ( /^\/(?:\^\$|\.\+|\.\*)\/$/.test(regex) ) { if ( /^\/(?:\^\$|\.\+|\.\*)\/$/.test(regex) ) {
throw new Error('Pattern should be replaced with empty string.\n' + app + ': ' + type + ': ' + pattern); throw new Error('Pattern should be replaced with empty string.\n' + app + ': ' + type + ': ' + pattern);
} }

Loading…
Cancel
Save