From 69ea3910361e22f2f0af806728122efc2acf3504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 28 Nov 2021 20:09:48 +0100 Subject: [PATCH] Fixed AS1/2 - newmethod proper brackets --- CHANGELOG.md | 1 + .../flash/action/model/NewMethodActionItem.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 357db6810..fe10c3e2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ All notable changes to this project will be documented in this file. - AS1/2 - parenthesis around callfunction - AS1/2 - deobfuscate function parameter names in registers - AS1/2 - direct editation - do..while +- AS1/2 - newmethod proper brackets ## [14.6.0] - 2021-11-22 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/NewMethodActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/NewMethodActionItem.java index c70627786..f32f16748 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/NewMethodActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/NewMethodActionItem.java @@ -16,6 +16,7 @@ */ 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.ActionNewMethod; import com.jpexs.decompiler.flash.ecma.Undefined; @@ -72,16 +73,21 @@ public class NewMethodActionItem extends ActionItem { } scriptObject.toString(writer, localData); if (!blankMethod) { - writer.append("."); if (methodName instanceof DirectValueActionItem) { if (((DirectValueActionItem) methodName).value == Undefined.INSTANCE) { - } else if (((DirectValueActionItem) methodName).value instanceof String) { + } else if ((((DirectValueActionItem) methodName).value instanceof String) + && (IdentifiersDeobfuscation.isValidName(false, (String) ((DirectValueActionItem) methodName).value))) { + writer.append("."); ((DirectValueActionItem) methodName).toStringNoQuotes(writer, localData); } else { + writer.append("["); methodName.toString(writer, localData); + writer.append("]"); } } else { + writer.append("["); methodName.toString(writer, localData); + writer.append("]"); } } writer.spaceBeforeCallParenthesies(arguments.size());