From 187edf15c92aeafc6f9e6bf707d78a18b0905acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Piotrowski?= Date: Fri, 3 Jul 2015 14:37:07 +0200 Subject: [PATCH 1/2] Added UTF char detection --- src/JShrink/Minifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JShrink/Minifier.php b/src/JShrink/Minifier.php index 55b3873..86734da 100644 --- a/src/JShrink/Minifier.php +++ b/src/JShrink/Minifier.php @@ -537,7 +537,7 @@ protected function saveRegex() */ protected static function isAlphaNumeric($char) { - return preg_match('/^[\w\$]$/', $char) === 1 || $char == '/'; + return preg_match('/^[\w\$\pL]$/', $char) === 1 || $char == '/'; } /** From 978bd442f3788211b51f94d3625c97d872a39e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Piotrowski?= Date: Fri, 3 Jul 2015 14:37:22 +0200 Subject: [PATCH 2/2] Added UTF Char detection Test --- tests/Resources/jshrink/input/utf_chars.js | 11 +++++++++++ tests/Resources/jshrink/output/utf_chars.js | 1 + 2 files changed, 12 insertions(+) create mode 100644 tests/Resources/jshrink/input/utf_chars.js create mode 100644 tests/Resources/jshrink/output/utf_chars.js diff --git a/tests/Resources/jshrink/input/utf_chars.js b/tests/Resources/jshrink/input/utf_chars.js new file mode 100644 index 0000000..dd9dc8f --- /dev/null +++ b/tests/Resources/jshrink/input/utf_chars.js @@ -0,0 +1,11 @@ +var π = Math.PI, + ε = 1e-6, + radians = π / 180, + degrees = 180 / π; + +function sgn(x) { + + + var π = Math.PI; + return x > 0 ? 1 : x < 0 ? -1 : 0; +} \ No newline at end of file diff --git a/tests/Resources/jshrink/output/utf_chars.js b/tests/Resources/jshrink/output/utf_chars.js new file mode 100644 index 0000000..7efc0e8 --- /dev/null +++ b/tests/Resources/jshrink/output/utf_chars.js @@ -0,0 +1 @@ +var π=Math.PI,ε=1e-6,radians=π/ 180,degrees=180 / π;function sgn(x){var π=Math.PI;return x>0?1:x<0?-1:0;} \ No newline at end of file