From 2e54f8426b20c118a9bdec63464a694acde5fd81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20Yaz=C4=B1c=C4=B1o=C4=9Flu?= Date: Mon, 26 Mar 2018 12:30:37 +0300 Subject: [PATCH] Add support for unicode regular expression flag The regular expression for matching valid JS regular expressions seems to be missing the `u` flag, which is a valid flag to treat a pattern as a sequence of unicode code points. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Advanced_searching_with_flags_2 --- src/JS.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JS.php b/src/JS.php index 0972d63..361afe3 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]+|(?:\\\\.)+)+\\])+)++\\/[gimy]*'; + $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