From cc0eb0cb6d6d6630415eb261a3101efefd694143 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 #252 Fixes #253 --- src/JS.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JS.php b/src/JS.php index 92ee63d..bbb9b8f 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