From a3cbcc7b19d66c4dcf0740c4022e54d747ce38ba Mon Sep 17 00:00:00 2001 From: Matthias Mullie Date: Mon, 26 Nov 2018 21:17:06 +0100 Subject: [PATCH] Improve regex detection Fixes #249 Fixes #253 --- src/JS.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JS.php b/src/JS.php index 361afe3..0caba10 100644 --- a/src/JS.php +++ b/src/JS.php @@ -238,7 +238,7 @@ protected function extractRegex() // closing the regex) // then also ignore bare `/` inside `[]`, where they don't need to be // escaped: anything inside `[]` can be ignored safely - $pattern = '\\/(?:[^\\[\\/\\\\\n\r]+|(?:\\\\.)+|(?:\\[(?:[^\\]\\\\\n\r]+|(?:\\\\.)+)+\\])+)++\\/[gimuy]*'; + $pattern = '\\/(?!\*)(?:[^\\[\\/\\\\\n\r]++|(?:\\\\.)++|(?:\\[(?:[^\\]\\\\\n\r]++|(?:\\\\.)++)++\\])++)++\\/[gimuy]*'; // a regular expression can only be followed by a few operators or some // of the RegExp methods (a `\` followed by a variable or value is