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

@@ -26,6 +26,7 @@ All notable changes to this project will be documented in this file.
- AS3 Direct editation - slow property resolving (Now up to 10 times faster compilation)
- [#1875] Garbage collect SWF and its caches after closing it
- [#1807] Proper parenthesis around call inside another call
- [#1840] AS3 - Allow to compile object literal keys with nonstring/numbers in obfuscated code
### Changed
- GFX - DefineExternalImage2 no longer handled as character
@@ -2612,6 +2613,7 @@ All notable changes to this project will be documented in this file.
[#1692]: https://www.free-decompiler.com/flash/issues/1692
[#1757]: https://www.free-decompiler.com/flash/issues/1757
[#1807]: https://www.free-decompiler.com/flash/issues/1807
[#1840]: https://www.free-decompiler.com/flash/issues/1840
[#1867]: https://www.free-decompiler.com/flash/issues/1867
[#1868]: https://www.free-decompiler.com/flash/issues/1868
[#1649]: https://www.free-decompiler.com/flash/issues/1649

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