Browse Source

Updated CHANGELOG.md. Fixed tests.

sanex 3 năm trước cách đây
mục cha
commit
73fcb350a2

+ 2 - 1
CHANGELOG.md

@@ -1,7 +1,8 @@
 Change Log
 
-v2.18.2
+v2.19.0
 ---
+* Improved `selfDefending` option
 * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/959
 
 v2.18.1

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/index.browser.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/index.cli.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/index.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "javascript-obfuscator",
-  "version": "2.18.2",
+  "version": "2.19.0",
   "description": "JavaScript obfuscator",
   "keywords": [
     "obfuscator",

+ 4 - 11
src/custom-code-helpers/string-array/StringArrayCodeHelper.ts

@@ -33,12 +33,6 @@ export class StringArrayCodeHelper extends AbstractCustomCodeHelper {
     @initializable()
     private stringArrayFunctionName!: string;
 
-    /**
-     * @type {string}
-     */
-    @initializable()
-    private stringArrayName!: string;
-
     /**
      * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
      * @param {ICustomCodeHelperFormatter} customCodeHelperFormatter
@@ -66,16 +60,13 @@ export class StringArrayCodeHelper extends AbstractCustomCodeHelper {
     /**
      * @param {IStringArrayStorage} stringArrayStorage
      * @param {string} stringArrayFunctionName
-     * @param {string} stringArrayName
      */
     public initialize (
         stringArrayStorage: IStringArrayStorage,
-        stringArrayFunctionName: string,
-        stringArrayName: string
+        stringArrayFunctionName: string
     ): void {
         this.stringArrayStorage = stringArrayStorage;
         this.stringArrayFunctionName = stringArrayFunctionName;
-        this.stringArrayName = stringArrayName;
     }
 
     /**
@@ -90,9 +81,11 @@ export class StringArrayCodeHelper extends AbstractCustomCodeHelper {
      * @returns {string}
      */
     protected override getCodeHelperTemplate (): string {
+        const stringArrayName: string = this.identifierNamesGenerator.generateNext();
+
         return this.customCodeHelperFormatter.formatTemplate(StringArrayTemplate(), {
             stringArrayFunctionName: this.stringArrayFunctionName,
-            stringArrayName: this.stringArrayName,
+            stringArrayName: stringArrayName,
             stringArrayStorageItems: this.getEncodedStringArrayStorageItems()
         });
     }

+ 1 - 3
src/custom-code-helpers/string-array/group/StringArrayCodeHelperGroup.ts

@@ -124,12 +124,10 @@ export class StringArrayCodeHelperGroup extends AbstractCustomCodeHelperGroup {
         // stringArray helper initialize
         const stringArrayCodeHelper: ICustomCodeHelper<TInitialData<StringArrayCodeHelper>> =
             this.customCodeHelperFactory(CustomCodeHelper.StringArray);
-        const stringArrayName: string = this.identifierNamesGenerator.generateNext();
 
         stringArrayCodeHelper.initialize(
             this.stringArrayStorage,
-            stringArrayFunctionName,
-            stringArrayName
+            stringArrayFunctionName
         );
         this.customCodeHelpers.set(CustomCodeHelper.StringArray, stringArrayCodeHelper);
 

+ 2 - 2
test/functional-tests/custom-code-helpers/string-array/StringArrayCallsWrapperCodeHelper.spec.ts

@@ -96,9 +96,9 @@ describe('StringArrayCallsWrapperCodeHelper', () => {
 
     describe('Preserve string array name', () => {
         const callsWrapperRegExp: RegExp = new RegExp(`` +
-            `function *c *\\(b, *d\\) *{ *` +
+            `function *b *\\(c, *d\\) *{ *` +
                 `var e *= *a\\(\\); *` +
-                `c *= *function *\\(f, *g\\) *{` +
+                `b *= *function *\\(f, *g\\) *{` +
                     `f *= *f *- *0x0; *` +
                     `var h *= *e\\[f]; *` +
         ``);

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

@@ -451,7 +451,7 @@ describe('JavaScriptObfuscator', () => {
                         'return foo_0x([a-f0-9]){4}\\(\\); *' +
                     '}'
                 );
-                const stringArrayCallRegExp: RegExp = /var foo_0x(\w){4,6} *= *foo_0x(\w){4}\(0x0\);$/;
+                const stringArrayCallRegExp: RegExp = /var foo_0x(\w){4,6} *= *foo_0x(\w){4}\(0x0\);/;
 
                 let obfuscatedCode: string;
 
@@ -543,7 +543,7 @@ describe('JavaScriptObfuscator', () => {
 
         describe('latin literal variable value', () => {
             const stringArrayLatinRegExp: RegExp = getStringArrayRegExp(['abc']);
-            const stringArrayCallRegExp: RegExp = /var test *= *_0x(\w){4}\(0x0\);$/;
+            const stringArrayCallRegExp: RegExp = /var test *= *_0x(\w){4}\(0x0\);/;
 
             let obfuscatedCode: string;
 
@@ -576,7 +576,7 @@ describe('JavaScriptObfuscator', () => {
                     'return _0x(\\w){4}\\(\\); *' +
                 '}'
             );
-            const stringArrayCallRegExp: RegExp = /var test *= *_0x(\w){4}\(0x0\);$/;
+            const stringArrayCallRegExp: RegExp = /var test *= *_0x(\w){4}\(0x0\);/;
 
             let obfuscatedCode: string;
 

+ 1 - 1
test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/black-list-obfuscating-guard/BlackListObfuscatingGuard.spec.ts

@@ -12,7 +12,7 @@ describe('BlackListObfuscatingGuard', () => {
         describe('`\'use strict\';` operator', () => {
             const useStrictOperatorRegExp: RegExp = /'use *strict';/;
             const stringArrayLatinRegExp: RegExp = getStringArrayRegExp(['abc']);
-            const stringArrayCallRegExp: RegExp = /var test *= *_0x(\w){4}\(0x0\);$/;
+            const stringArrayCallRegExp: RegExp = /var test *= *_0x(\w){4}\(0x0\)/;
 
             let obfuscatedCode: string;
 

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác