Skip to content

Commit d04f0bf

Browse files
committed
fix: inlined control flow function that isn't called
1 parent 05abe0c commit d04f0bf

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

packages/webcrack/src/deobfuscate/control-flow-object.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,10 @@ export default {
239239

240240
if (t.isStringLiteral(value)) {
241241
path.replaceWith(value);
242+
} else if (path.parentPath.isCallExpression()) {
243+
inlineFunction(value, path.parentPath);
242244
} else {
243-
inlineFunction(
244-
value,
245-
path.parentPath as NodePath<t.CallExpression>,
246-
);
245+
path.replaceWith(value);
247246
}
248247
this.changes++;
249248
},

packages/webcrack/src/deobfuscate/test/control-flow-object.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ test('inlined object', () => {
1414
}).QuFtJ(u, undefined);
1515
`).toMatchInlineSnapshot(`u === undefined;`);
1616

17+
expectJS(`
18+
a = ({
19+
QuFtJ: function (n, r) {
20+
return n === r;
21+
}
22+
}).QuFtJ;
23+
`).toMatchInlineSnapshot(`
24+
a = function (n, r) {
25+
return n === r;
26+
};
27+
`);
28+
1729
expectJS(`
1830
({ YhxvC: "default" }).YhxvC;
1931
`).toMatchInlineSnapshot(`"default";`);

0 commit comments

Comments
 (0)