Explorar o código

Merge pull request #731 from javascript-obfuscator/fixed-converting-and-split-strings-transformers-order

Fixed regression bug with combination of `splitStrings` and `renameProperties` option
Timofey Kachalov %!s(int64=4) %!d(string=hai) anos
pai
achega
55862e9c01

+ 1 - 0
CHANGELOG.md

@@ -3,6 +3,7 @@ Change Log
 v2.0.0
 ---
 * **Breaking change:** `stringArrayEncoding` option now accepts an array of encodings. Each string will be randomly encoded with passed encoding.
+* Fixed regression bug with combination of `splitStrings` and `renameProperties` option. https://github.com/javascript-obfuscator/javascript-obfuscator/issues/729
 
 v1.12.0
 ---

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
dist/index.browser.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
dist/index.cli.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
dist/index.js


+ 1 - 2
src/JavaScriptObfuscator.ts

@@ -217,12 +217,11 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
             astTree = this.runNodeTransformationStage(astTree, NodeTransformationStage.ControlFlowFlattening);
         }
 
-        astTree = this.runNodeTransformationStage(astTree, NodeTransformationStage.Converting);
-
         if (this.options.renameProperties) {
             astTree = this.runNodeTransformationStage(astTree, NodeTransformationStage.RenameProperties);
         }
 
+        astTree = this.runNodeTransformationStage(astTree, NodeTransformationStage.Converting);
         astTree = this.runNodeTransformationStage(astTree, NodeTransformationStage.RenameIdentifiers);
         astTree = this.runNodeTransformationStage(astTree, NodeTransformationStage.StringArray);
 

+ 6 - 1
test/functional-tests/node-transformers/rename-properties-transformers/rename-properties-transformer/RenamePropertiesTransformer.spec.ts

@@ -294,7 +294,12 @@ describe('RenamePropertiesTransformer', () => {
             });
 
             describe('Variant #8: integration with `splitStrings` option', () => {
-                const propertyRegExp: RegExp = /'a': *'long' *\+ *'Prop' *\+ *'erty' *\+ *'Valu' *\+ *'e'/;
+                const propertyRegExp: RegExp = new RegExp(
+                    'const foo *= *{' +
+                        '\'a\': *\'long\' *\\+ *\'Prop\' *\\+ *\'erty\' *\\+ *\'Valu\' *\\+ *\'e\'' +
+                    '};' +
+                    'foo\\[\'a\'];'
+                );
 
                 let obfuscatedCode: string;
 

+ 1 - 0
test/functional-tests/node-transformers/rename-properties-transformers/rename-properties-transformer/fixtures/split-strings-integration.js

@@ -1,3 +1,4 @@
 const foo = {
     longPropertyName: 'longPropertyValue'
 };
+foo.longPropertyName;

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio