diff --git a/CHANGELOG.md b/CHANGELOG.md index 809f86026..cd8b1869c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file. - AS1/2 getProperty, setProperty handling - AS1/2 callmethod action arguments - Fixed §§push after continue - should be before (usually on obfuscated code) +- AS1/2 Delete operator with nonIdentifier parameters (e.g. spaces or obfuscated) ## [11.1.0] - 2018-05-24 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DeleteActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DeleteActionItem.java index c99a05a67..d959881fa 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DeleteActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DeleteActionItem.java @@ -12,9 +12,11 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.model; +import com.jpexs.decompiler.flash.IdentifiersDeobfuscation; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.action.swf5.ActionDelete; import com.jpexs.decompiler.flash.action.swf5.ActionDelete2; @@ -55,12 +57,25 @@ public class DeleteActionItem extends ActionItem { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { writer.append("delete "); - if (object == null) { - return propertyName.toStringNoQuotes(writer, localData); + if (object != null) { + object.toStringNoQuotes(writer, localData); + if (IdentifiersDeobfuscation.isValidName(false, propertyName.toStringNoQuotes(localData))) { + writer.append("."); + propertyName.toStringNoQuotes(writer, localData); + } else { + writer.append("["); + propertyName.toString(writer, localData); + writer.append("]"); + } + return writer; } - object.toStringNoQuotes(writer, localData); - writer.append("."); - return propertyName.toStringNoQuotes(writer, localData); + + if (IdentifiersDeobfuscation.isValidName(false, propertyName.toStringNoQuotes(localData))) { + propertyName.toStringNoQuotes(writer, localData); + } else { + propertyName.toString(writer, localData); + } + return writer; } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java index 549578acb..e802d87da 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java @@ -606,6 +606,8 @@ public class ActionScript2Parser { } else if (varDel instanceof VariableActionItem) { variables.remove(varDel); ret = new DeleteActionItem(null, null, null, pushConst(((VariableActionItem) varDel).getVariableName())); + } else if (varDel instanceof DirectValueActionItem) { + ret = new DeleteActionItem(null, null, null, varDel); } else { throw new ActionParseException("Not a property", lexer.yyline()); } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java index c795f2895..736861e60 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java @@ -2018,4 +2018,15 @@ public class ActionScript2Test extends ActionScript2TestBase { + "trace(\"forInSwitchTest\");\r\n" ); } + + @Test + public void frame73_deleteTest() { + compareSrc(73, "trace(\"deleteTest\");\r\n" + + "var obj = {a:1,b:2};\r\n" + + "obj[\"salam likum\"] = 58;\r\n" + + "delete obj.a;\r\n" + + "delete obj[\"salam likum\"];\r\n" + + "delete \"bagr aa\";\r\n" + ); + } } diff --git a/libsrc/ffdec_lib/testdata/as2/as2.fla b/libsrc/ffdec_lib/testdata/as2/as2.fla index 4e3137e88..b5e50589a 100644 Binary files a/libsrc/ffdec_lib/testdata/as2/as2.fla and b/libsrc/ffdec_lib/testdata/as2/as2.fla differ diff --git a/libsrc/ffdec_lib/testdata/as2/as2.swf b/libsrc/ffdec_lib/testdata/as2/as2.swf index 5d076ded8..c7dcb512b 100644 Binary files a/libsrc/ffdec_lib/testdata/as2/as2.swf and b/libsrc/ffdec_lib/testdata/as2/as2.swf differ