diff --git a/CHANGELOG.md b/CHANGELOG.md index ae4c3781f..ec7e4d34d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## [Unreleased] ### Fixed - AS 1/2 - do not use eval function on obfuscated increment/decrement +- AS 1/2 direct editation - newline as "\n", not "\r" +- AS 1/2 allow various nonstandard names for definelocal ## [14.5.0] - 2021-11-19 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java index 9f9eee922..2ddf88cfe 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java @@ -71,20 +71,34 @@ public class IdentifiersDeobfuscation { public static final String[] reservedWordsAS2 = { // is "add" really a keyword? documentation says yes, but I can create "add" variable in CS6... // "add", - "and", "break", "case", "catch", "class", "continue", "default", "delete", "do", "dynamic", "else", - "eq", "extends", "false", "finally", "for", "function", "ge", "get", "gt", "if", "ifFrameLoaded", "implements", + "and", "break", "case", "catch", "class", "continue", "default", "delete", "do", "dynamic", + "each", //can be in variable definition + "else", + "eq", "extends", + "false", //can be in variable definition + "finally", "for", "function", "ge", + "get", //can be in variable definition + "gt", "if", "ifFrameLoaded", "implements", "import", "in", "instanceof", "interface", "intrinsic", "le", // is "it" really a keyword? documentation says yes, but I can create "it" variable in CS6... // "it", - "ne", "new", "not", "null", "on", "onClipEvent", - "or", "private", "public", "return", "set", "static", + "ne", "new", "not", + "null", //can be in variable definition + "on", "onClipEvent", + "or", "private", "public", "return", + "set", //can be in variable definition + "static", //allow as variable: //"super", "switch", "tellTarget", //allow as variable: //"this", - "throw", "try", - "typeof", "undefined", "var", "void", "while", "with" + "throw", + "true", //can be in variable definition + "try", + "typeof", "undefined", "var", "void", "while", "with", + //global constants, can be in variable definition : + "NaN", "newline", "Infinity" }; // http://www.adobe.com/devnet/actionscript/learning/as3-fundamentals/syntax.html diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DefineLocalActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DefineLocalActionItem.java index a5eabce3d..65e3aa04a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DefineLocalActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DefineLocalActionItem.java @@ -83,7 +83,8 @@ public class DefineLocalActionItem extends ActionItem implements SetTypeActionIt HighlightData srcData = getSrcData(); srcData.localName = name.toStringNoQuotes(localData); srcData.declaration = true; - if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) { + if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), + "this", "super", "true", "false", "NaN", "null", "newline", "Infinity", "undefined", "get", "set", "each"))) { IdentifiersDeobfuscation.appendObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData), writer); } else { stripQuotes(name, localData, writer); 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 0d50ebb40..e50a0e93c 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 @@ -1003,7 +1003,10 @@ public class ActionScript2Parser { break; case VAR: s = lex(); - expected(s, lexer.yyline(), SymbolType.IDENTIFIER); + expected(s, lexer.yyline(), SymbolType.IDENTIFIER, + SymbolType.TRUE, SymbolType.FALSE, SymbolGroup.GLOBALCONST, + SymbolType.GET, SymbolType.SET, + SymbolType.EACH); String varIdentifier = s.value.toString(); s = lex(); if (s.type == SymbolType.COLON) { @@ -1783,7 +1786,7 @@ public class ActionScript2Parser { allowMemberOrCall = true; break; case NEWLINE: - ret = new DirectValueActionItem(null, null, 0, "\r", new ArrayList<>()); + ret = new DirectValueActionItem(null, null, 0, "\n", new ArrayList<>()); allowMemberOrCall = true; break; case NAN: