Fixed AS 1/2 direct editation - newline as "\n", not "\r"

Fixed AS 1/2 allow various nonstandard names for definelocal
This commit is contained in:
Jindra Petřík
2021-11-20 13:10:10 +01:00
parent 4070ada026
commit f24ad2dde1
4 changed files with 29 additions and 9 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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: