Fixed #1840 AS3 - Allow to compile object literal keys with nonstring/numbers in obfuscated code

This commit is contained in:
Jindra Petřík
2022-11-18 16:03:48 +01:00
parent 06feae4113
commit f90f5fbd32
3 changed files with 18 additions and 4 deletions

View File

@@ -46,8 +46,15 @@ public class NameValuePair extends AVM2Item {
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
boolean needsParents = !((name.getNotCoerced() instanceof NumberValueAVM2Item) || (name.getNotCoerced() instanceof StringAVM2Item)); // special for obfuscated strings
if (needsParents) {
writer.append("(");
}
name.toStringString(writer, localData);
if (needsParents) {
writer.append(")");
}
writer.append(":");
if (value instanceof TernarOpItem) { //Ternar operator contains ":"
writer.append("(");

View File

@@ -2351,10 +2351,15 @@ public class ActionScript3Parser {
lexer.pushback(s);
}
s = lex();
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.STRING, SymbolType.INTEGER, SymbolType.DOUBLE);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.STRING, SymbolType.INTEGER, SymbolType.DOUBLE, SymbolType.PARENT_OPEN);
GraphTargetItem n = new StringAVM2Item(null, null, s.value.toString());
//expression(allOpenedNamespaces, thisType,pkg,needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables);
GraphTargetItem n;
if (s.type == SymbolType.PARENT_OPEN) { //special for obfuscated SWFs
n = expression(allOpenedNamespaces, thisType,pkg,needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables, false);
expectedType(SymbolType.PARENT_CLOSE);
} else {
n = new StringAVM2Item(null, null, s.value.toString());
}
expectedType(SymbolType.COLON);
GraphTargetItem v = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables, false);