Jelajahi Sumber

Merge pull request #547 from javascript-obfuscator/exponentiation-operator-fix

Fixed support of exponentiation operator
Timofey Kachalov 5 tahun lalu
induk
melakukan
43b8fc9d7c

+ 1 - 0
CHANGELOG.md

@@ -2,6 +2,7 @@ Change Log
 
 v0.24.6
 ---
+* Fixed support of exponentiation operator. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/534
 * Added file path to the error message during directory obfuscation. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/513
 
 v0.24.5

File diff ditekan karena terlalu besar
+ 0 - 0
dist/index.browser.js


+ 1 - 1
package.json

@@ -29,7 +29,7 @@
     "chance": "1.1.4",
     "class-validator": "0.11.0",
     "commander": "4.1.1",
-    "escodegen": "1.13.0",
+    "escodegen": "1.14.1",
     "eslint-scope": "5.0.0",
     "estraverse": "4.3.0",
     "eventemitter3": "4.0.0",

+ 24 - 0
test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts

@@ -572,6 +572,30 @@ describe('JavaScriptObfuscator', () => {
             });
         });
 
+        /**
+         * https://github.com/estools/escodegen/pull/407
+         */
+        describe('valid exponentiation operator precedence', () => {
+            const regExp: RegExp = /var foo *= *\( *0x1 *- *0x2 *\) *\*\* *0x2;/;
+
+            let obfuscatedCode: string;
+
+            beforeEach(() => {
+                const code: string = readFileAsString(__dirname + '/fixtures/exponentiation-operator-precedence.js');
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
+                    code,
+                    {
+                        ...NO_ADDITIONAL_NODES_PRESET
+                    }
+                ).getObfuscatedCode();
+            });
+
+            it('should support exponentiation operator', () => {
+                assert.match(obfuscatedCode, regExp);
+            });
+        });
+
         describe('mangled identifier names generator', () => {
             const regExp: RegExp = /var c *= *0x1/;
 

+ 1 - 0
test/functional-tests/javascript-obfuscator/fixtures/exponentiation-operator-precedence.js

@@ -0,0 +1 @@
+var foo = (1-2) ** 2;

+ 4 - 4
yarn.lock

@@ -1714,10 +1714,10 @@ [email protected], escape-string-regexp@^1.0.2, escape-string-regexp@^1
   resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
   integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
 
[email protected]3.0:
-  version "1.13.0"
-  resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.13.0.tgz#c7adf9bd3f3cc675bb752f202f79a720189cab29"
-  integrity sha512-eYk2dCkxR07DsHA/X2hRBj0CFAZeri/LyDMc0C8JT1Hqi6JnVpMhJ7XFITbb0+yZS3lVkaPL2oCkZ3AVmeVbMw==
[email protected]4.1:
+  version "1.14.1"
+  resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.1.tgz#ba01d0c8278b5e95a9a45350142026659027a457"
+  integrity sha512-Bmt7NcRySdIfNPfU2ZoXDrrXsG9ZjvDxcAlMfDUgRBjLOWTuIACXPBFJH7Z+cLb40JeQco5toikyc9t9P8E9SQ==
   dependencies:
     esprima "^4.0.1"
     estraverse "^4.2.0"

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini