mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
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:
+4
-1
@@ -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
|
||||
|
||||
Vendored
+3
-3
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -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
@@ -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();
|
||||
|
||||
|
||||
+4
-4
@@ -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'};$/);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
var test = {
|
||||
'abcdefg': 1
|
||||
};
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
var test = {
|
||||
'abcdefg': 'abcdefg'
|
||||
};
|
||||
Reference in New Issue
Block a user