Merge pull request #458 from javascript-obfuscator/split-string-template-literal

The `splitStrings` option now correctly splits strings inside objects
This commit is contained in:
Timofey Kachalov
2019-12-29 13:45:34 +03:00
committed by GitHub
10 changed files with 24 additions and 19 deletions
+4 -1
View File
@@ -1,10 +1,13 @@
Change Log
v0.19.2
---
* The `splitStrings` option now correctly splits strings inside objects
v0.19.1
---
* The `splitStrings` option now affects template literal strings
v0.19.0
---
* **New option:** `splitStrings` splits literal strings into chunks with length of `splitStringsChunkLength` option value
+3 -3
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "javascript-obfuscator",
"version": "0.19.1",
"version": "0.19.2",
"description": "JavaScript obfuscator",
"keywords": [
"obfuscator",
@@ -85,7 +85,7 @@ export class SplitStringTransformer extends AbstractNodeTransformer {
return literalNode;
}
if (NodeGuards.isPropertyNode(parentNode) && !parentNode.computed) {
if (NodeGuards.isPropertyNode(parentNode) && !parentNode.computed && parentNode.key === literalNode) {
return literalNode;
}
+6 -4
View File
@@ -6,16 +6,18 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNo
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
`
var n = 'abcefgi';
function hi() {
console.log("Hello World!");
}
hi();
`,
{
...NO_ADDITIONAL_NODES_PRESET,
compact: false,
splitStrings: true,
splitStringsChunkLength: 4,
stringArray: true,
stringArrayThreshold: 1,
seed: 1
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1
}
).getObfuscatedCode();
@@ -129,9 +129,9 @@ describe('SplitStringTransformer', () => {
});
});
describe('Variant #8: object key string literal', () => {
it('should keep original string literal', () => {
const code: string = readFileAsString(__dirname + '/fixtures/object-key-string-literal.js');
describe('Variant #8: object string literal', () => {
it('should keep original key string literal and transform value string literal', () => {
const code: string = readFileAsString(__dirname + '/fixtures/object-string-literal.js');
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
@@ -142,7 +142,7 @@ describe('SplitStringTransformer', () => {
}
).getObfuscatedCode();
assert.match(obfuscatedCode, /^var *test *= *{'abcdefg' *: *0x1};$/);
assert.match(obfuscatedCode, /^var *test *= *{'abcdefg' *: *'ab' *\+ *'cd' *\+ *'ef' *\+ *'g'};$/);
});
});