From 5cd2b9d6c0a92ffc7dd3aebab062d3c5318aa33f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Mon, 29 Nov 2021 11:23:07 +0100 Subject: [PATCH] Fixed AS1/2 - chained assignments with obfuscated/slash variables --- CHANGELOG.md | 1 + .../action/model/SetVariableActionItem.java | 22 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15a9ea364..c373462fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ All notable changes to this project will be documented in this file. - AS2 - obfuscated class attribute names - AS1/2 - newobject deobfuscated name - AS2 - obfuscated extends, implements +- AS1/2 - chained assignments with obfuscated/slash variables ## [14.6.0] - 2021-11-22 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java index b64e0c473..9faa7884f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java @@ -80,13 +80,29 @@ public class SetVariableActionItem extends ActionItem implements SetTypeActionIt this.name = name; } + private boolean resultNeeded() { + boolean needsTempRegister = false; + if (value instanceof StoreRegisterActionItem) { + StoreRegisterActionItem sr = (StoreRegisterActionItem) value; + if (sr.temporary) { + needsTempRegister = true; + } + } + return needsTempRegister; + } + + private boolean isValidName(LocalData localData) { + return ((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) + && (IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super")); + } + @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) - && (IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) { + if (isValidName(localData) || resultNeeded()) { + //TODO: handle result needed better, without identifierdeobfuscation HighlightData srcData = getSrcData(); srcData.localName = name.toStringNoQuotes(localData); - stripQuotes(name, localData, writer); + writer.append(IdentifiersDeobfuscation.printIdentifier(false, name.toStringNoQuotes(localData))); if (compoundOperator != null) { writer.append(" "); writer.append(compoundOperator);