From 5d951b30cf986026d226f410b85d55fb10853c04 Mon Sep 17 00:00:00 2001 From: Khanh Nguyen Date: Fri, 15 Dec 2023 02:43:03 +0700 Subject: [PATCH] fix: cannot find decoder, proxy functions because of some empty statements --- src/transformers/demangle.ts | 3 ++- src/transformers/stringdecoder.ts | 9 ++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/transformers/demangle.ts b/src/transformers/demangle.ts index 1d9d439..4c767c1 100644 --- a/src/transformers/demangle.ts +++ b/src/transformers/demangle.ts @@ -1,5 +1,4 @@ import { - Program, BlockStatement, sp, Function, @@ -17,6 +16,7 @@ import { Transformer, TransformerOptions } from './transformer' import { walk } from '../util/walk' import * as Guard from '../util/guard' import Context from '../context' +import { filterEmptyStatements } from '../util/helpers' export interface DemangleOptions extends TransformerOptions {} export default class Demangle extends Transformer { @@ -29,6 +29,7 @@ export default class Demangle extends Transformer { demangleProxies(context: Context) { function visitor(func: Function) { if (!Guard.isBlockStatement(func.body)) return + func.body.body = filterEmptyStatements(func.body.body) as Statement[]; if (func.body.body.length !== 2) return let body = func.body.body diff --git a/src/transformers/stringdecoder.ts b/src/transformers/stringdecoder.ts index 47c9718..0e5bb7a 100644 --- a/src/transformers/stringdecoder.ts +++ b/src/transformers/stringdecoder.ts @@ -1,19 +1,13 @@ import { - Program, - BlockStatement, Node, sp, VariableDeclaration, - ExpressionStatement, - ReturnStatement, - CallExpression, FunctionExpression, AssignmentExpression, StringLiteral, Identifier, Statement, Literal, - UnaryExpression, Expression, BinaryExpression, VariableDeclarator, @@ -338,7 +332,8 @@ export default class StringDecoder extends Transformer { const block = node.body const fnId = node.id.name - if (block.body.length > 3 && block.body.length < 1) return + block.body = filterEmptyStatements(block.body) as Statement[]; + if (block.body.length > 3 || block.body.length < 1) return if (!block.body[0]) return // stringArray declaration if (