Issue #698 Better obfuscated identifiers handling, separated reserved keyword for AS2/AS3

This commit is contained in:
Jindra Petřík
2014-11-04 20:51:39 +01:00
parent b4aeb0f80f
commit 342247d5d2
20 changed files with 2124 additions and 2281 deletions

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.action;
package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.abc.RenameType;
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
@@ -32,7 +32,7 @@ import java.util.regex.Pattern;
*
* @author JPEXS
*/
public class Deobfuscation {
public class IdentifiersDeobfuscation {
private final Random rnd = new Random();
private final int DEFAULT_FOO_SIZE = 10;
@@ -44,7 +44,48 @@ public class Deobfuscation {
public static final String FOO_CHARACTERS = "bcdfghjklmnpqrstvwz";
public static final String FOO_JOIN_CHARACTERS = "aeiouy";
private String fooString(HashMap<String, String> deobfuscated, String orig, boolean firstUppercase, int rndSize) {
//http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000477.html
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",
"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","super","switch","tellTarget","this","throw","try",
"typeof","undefined","var","void","while","with"
};
//http://www.adobe.com/devnet/actionscript/learning/as3-fundamentals/syntax.html
public static final String[] reservedWordsAS3 = {
"as", "break", "case", "catch", "class", "const", "continue", "default", "delete", "do", "else",
"extends", "false", "finally", "for", "function", "if", "implements", "import", "in", "instanceof",
"interface", "internal", "is", "new", "null", "package", "private", "protected", "public",
"return", "super", "switch", "this", "throw",
//is "to" really a keyword? documentation says yes, but I can create "to" variable...
// "to",
"true", "try", "typeof", "use", "var",
"void","while","with"
};
//syntactic keywords - can be used as identifiers, but that have special meaning in certain contexts
public static final String[] syntacticKeywordsAS3= {"each", "get", "set", "namespace", "include", "dynamic", "final", "native", "override", "static"};
public static boolean isReservedWord(String s,boolean as3) {
if (s == null) {
return false;
}
String reservedWords[] = as3?reservedWordsAS3:reservedWordsAS2;
for (String rw : reservedWords) {
if (rw.equals(s.trim())) {
return true;
}
}
return false;
}
private String fooString(boolean as3,HashMap<String, String> deobfuscated, String orig, boolean firstUppercase, int rndSize) {
boolean exists;
String ret;
loopfoo:
@@ -69,7 +110,7 @@ public class Deobfuscation {
rndSize += 1;
continue loopfoo;
}
if (Action.isReservedWord(ret)) {
if (isReservedWord(ret,as3)) {
exists = true;
rndSize += 1;
continue;
@@ -83,16 +124,16 @@ public class Deobfuscation {
return ret;
}
public void deobfuscateInstanceNames(HashMap<String, String> namesMap, RenameType renameType, List<Tag> tags, Map<String, String> selected) {
public void deobfuscateInstanceNames(boolean as3,HashMap<String, String> namesMap, RenameType renameType, List<Tag> tags, Map<String, String> selected) {
for (Tag t : tags) {
if (t instanceof DefineSpriteTag) {
deobfuscateInstanceNames(namesMap, renameType, ((DefineSpriteTag) t).subTags, selected);
deobfuscateInstanceNames(as3,namesMap, renameType, ((DefineSpriteTag) t).subTags, selected);
}
if (t instanceof PlaceObjectTypeTag) {
PlaceObjectTypeTag po = (PlaceObjectTypeTag) t;
String name = po.getInstanceName();
if (name != null) {
String changedName = deobfuscateName(name, false, "instance", namesMap, renameType, selected);
String changedName = deobfuscateName(as3,name, false, "instance", namesMap, renameType, selected);
if (changedName != null) {
po.setInstanceName(changedName);
((Tag) po).setModified(true);
@@ -100,7 +141,7 @@ public class Deobfuscation {
}
String className = po.getClassName();
if (className != null) {
String changedClassName = deobfuscateNameWithPackage(className, namesMap, renameType, selected);
String changedClassName = deobfuscateNameWithPackage(as3,className, namesMap, renameType, selected);
if (changedClassName != null) {
po.setClassName(changedClassName);
((Tag) po).setModified(true);
@@ -110,7 +151,7 @@ public class Deobfuscation {
}
}
public String deobfuscatePackage(String pkg, HashMap<String, String> namesMap, RenameType renameType, Map<String, String> selected) {
public String deobfuscatePackage(boolean as3,String pkg, HashMap<String, String> namesMap, RenameType renameType, Map<String, String> selected) {
if (namesMap.containsKey(pkg)) {
return namesMap.get(pkg);
}
@@ -126,7 +167,7 @@ public class Deobfuscation {
if (p > 0) {
ret += ".";
}
String partChanged = deobfuscateName(parts[p], false, "package", namesMap, renameType, selected);
String partChanged = deobfuscateName(as3,parts[p], false, "package", namesMap, renameType, selected);
if (partChanged != null) {
ret += partChanged;
isChanged = true;
@@ -141,7 +182,7 @@ public class Deobfuscation {
return null;
}
public String deobfuscateNameWithPackage(String n, HashMap<String, String> namesMap, RenameType renameType, Map<String, String> selected) {
public String deobfuscateNameWithPackage(boolean as3,String n, HashMap<String, String> namesMap, RenameType renameType, Map<String, String> selected) {
String pkg = null;
String name = "";
if (n.contains(".")) {
@@ -152,13 +193,13 @@ public class Deobfuscation {
}
boolean changed = false;
if ((pkg != null) && (!pkg.isEmpty())) {
String changedPkg = deobfuscatePackage(pkg, namesMap, renameType, selected);
String changedPkg = deobfuscatePackage(as3,pkg, namesMap, renameType, selected);
if (changedPkg != null) {
changed = true;
pkg = changedPkg;
}
}
String changedName = deobfuscateName(name, true, "class", namesMap, renameType, selected);
String changedName = deobfuscateName(as3,name, true, "class", namesMap, renameType, selected);
if (changedName != null) {
changed = true;
name = changedName;
@@ -175,7 +216,7 @@ public class Deobfuscation {
return null;
}
public static boolean isValidName(String s, String... exceptions) {
public static boolean isValidName(boolean as3,String s, String... exceptions) {
boolean isValid = true;
for (String e : exceptions) {
@@ -184,7 +225,7 @@ public class Deobfuscation {
}
}
if (Action.isReservedWord(s)) {
if (isReservedWord(s,as3)) {
isValid = false;
}
@@ -206,7 +247,7 @@ public class Deobfuscation {
return isValid;
}
public String deobfuscateName(String s, boolean firstUppercase, String usageType, HashMap<String, String> namesMap, RenameType renameType, Map<String, String> selected) {
public String deobfuscateName(boolean as3,String s, boolean firstUppercase, String usageType, HashMap<String, String> namesMap, RenameType renameType, Map<String, String> selected) {
boolean isValid = true;
if (usageType == null) {
usageType = "name";
@@ -218,7 +259,7 @@ public class Deobfuscation {
}
}
isValid = isValidName(s);
isValid = isValidName(as3,s);
if (!isValid) {
if (namesMap.containsKey(s)) {
return namesMap.get(s);
@@ -240,7 +281,7 @@ public class Deobfuscation {
} while (found);
typeCounts.put(usageType, cnt);
} else if (renameType == RenameType.RANDOMWORD) {
ret = fooString(namesMap, s, firstUppercase, DEFAULT_FOO_SIZE);
ret = fooString(as3,namesMap, s, firstUppercase, DEFAULT_FOO_SIZE);
}
namesMap.put(s, ret);
return ret;
@@ -263,14 +304,14 @@ public class Deobfuscation {
* words)
* @return
*/
public static String printIdentifier(String s, String... validExceptions) {
public static String printIdentifier(boolean as3, String s, String... validExceptions) {
if (s.startsWith("\u00A7") && s.endsWith("\u00A7")) { //Assuming already printed - TODO:detect better
return s;
}
if (nameCache.containsKey(s)) {
return nameCache.get(s);
}
if (isValidName(s, validExceptions)) {
if (isValidName(as3, s, validExceptions)) {
nameCache.put(s, s);
return s;
}
@@ -279,7 +320,7 @@ public class Deobfuscation {
return ret;
}
public static String printNamespace(String pkg, String... validNameExceptions) {
public static String printNamespace(boolean as3,String pkg, String... validNameExceptions) {
if (nameCache.containsKey(pkg)) {
return nameCache.get(pkg);
}
@@ -298,7 +339,7 @@ public class Deobfuscation {
if (i > 0) {
ret += ".";
}
ret += printIdentifier(parts[i], validNameExceptions);
ret += printIdentifier(as3,parts[i], validNameExceptions);
}
nameCache.put(pkg, ret);
return ret;

View File

@@ -27,7 +27,7 @@ import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraphSource;
import com.jpexs.decompiler.flash.action.ActionList;
import com.jpexs.decompiler.flash.action.ActionLocalData;
import com.jpexs.decompiler.flash.action.Deobfuscation;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.action.model.ConstantPool;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
@@ -1676,7 +1676,7 @@ public final class SWF implements TreeItem, Timelined {
private List<GraphSourceItem> allFunctions = new ArrayList<>();
private HashMap<DirectValueActionItem, ConstantPool> allStrings = new HashMap<>();
private final HashMap<DirectValueActionItem, String> usageTypes = new HashMap<>();
private final Deobfuscation deobfuscation = new Deobfuscation();
private final IdentifiersDeobfuscation deobfuscation = new IdentifiersDeobfuscation();
private static void getVariables(ConstantPool constantPool, BaseLocalData localData, TranslateStack stack, List<GraphTargetItem> output, ActionGraphSource code, int ip, List<MyEntry<DirectValueActionItem, ConstantPool>> variables, List<GraphSourceItem> functions, HashMap<DirectValueActionItem, ConstantPool> strings, List<Integer> visited, HashMap<DirectValueActionItem, String> usageTypes, String path) throws InterruptedException {
boolean debugMode = false;
@@ -1893,7 +1893,7 @@ public final class SWF implements TreeItem, Timelined {
if (tag instanceof SymbolClassTag) {
SymbolClassTag sc = (SymbolClassTag) tag;
for (int i = 0; i < sc.names.length; i++) {
String newname = deobfuscation.deobfuscateNameWithPackage(sc.names[i], deobfuscated, renameType, deobfuscated);
String newname = deobfuscation.deobfuscateNameWithPackage(true,sc.names[i], deobfuscated, renameType, deobfuscated);
if (newname != null) {
sc.names[i] = newname;
}
@@ -1901,7 +1901,7 @@ public final class SWF implements TreeItem, Timelined {
sc.setModified(true);
}
}
deobfuscation.deobfuscateInstanceNames(deobfuscated, renameType, tags, new HashMap<String, String>());
deobfuscation.deobfuscateInstanceNames(true,deobfuscated, renameType, tags, new HashMap<String, String>());
return deobfuscated.size();
}
@@ -1993,7 +1993,7 @@ public final class SWF implements TreeItem, Timelined {
if (fun.calculatedFunctionName instanceof DirectValueActionItem) {
DirectValueActionItem dvf = (DirectValueActionItem) fun.calculatedFunctionName;
String fname = dvf.toStringNoH(null);
String changed = deobfuscation.deobfuscateName(fname, false, "method", deobfuscated, renameType, selected);
String changed = deobfuscation.deobfuscateName(false,fname, false, "method", deobfuscated, renameType, selected);
if (changed != null) {
deobfuscated.put(fname, changed);
}
@@ -2012,7 +2012,7 @@ public final class SWF implements TreeItem, Timelined {
if (gti instanceof DirectValueActionItem) {
DirectValueActionItem dvf = (DirectValueActionItem) gti;
String vname = dvf.toStringNoH(null);
String changed = deobfuscation.deobfuscateName(vname, false, "attribute", deobfuscated, renameType, selected);
String changed = deobfuscation.deobfuscateName(false,vname, false, "attribute", deobfuscated, renameType, selected);
if (changed != null) {
deobfuscated.put(vname, changed);
}
@@ -2045,7 +2045,7 @@ public final class SWF implements TreeItem, Timelined {
if (classNameParts != null) {
changedNameStr = classNameParts[classNameParts.length - 1 - pos];
}
String changedNameStr2 = deobfuscation.deobfuscateName(changedNameStr, pos == 0, pos == 0 ? "class" : "package", deobfuscated, renameType, selected);
String changedNameStr2 = deobfuscation.deobfuscateName(false,changedNameStr, pos == 0, pos == 0 ? "class" : "package", deobfuscated, renameType, selected);
if (changedNameStr2 != null) {
changedNameStr = changedNameStr2;
}
@@ -2069,7 +2069,7 @@ public final class SWF implements TreeItem, Timelined {
if (classNameParts != null) {
changedNameStr = classNameParts[classNameParts.length - 1 - pos];
}
String changedNameStr2 = deobfuscation.deobfuscateName(changedNameStr, pos == 0, pos == 0 ? "class" : "package", deobfuscated, renameType, selected);
String changedNameStr2 = deobfuscation.deobfuscateName(false,changedNameStr, pos == 0, pos == 0 ? "class" : "package", deobfuscated, renameType, selected);
if (changedNameStr2 != null) {
changedNameStr = changedNameStr2;
}
@@ -2091,7 +2091,7 @@ public final class SWF implements TreeItem, Timelined {
if (f.functionName.isEmpty()) { //anonymous function, leave as is
continue;
}
String changed = deobfuscation.deobfuscateName(f.functionName, false, "function", deobfuscated, renameType, selected);
String changed = deobfuscation.deobfuscateName(false,f.functionName, false, "function", deobfuscated, renameType, selected);
if (changed != null) {
f.replacedFunctionName = changed;
ret++;
@@ -2102,7 +2102,7 @@ public final class SWF implements TreeItem, Timelined {
if (f.functionName.isEmpty()) { //anonymous function, leave as is
continue;
}
String changed = deobfuscation.deobfuscateName(f.functionName, false, "function", deobfuscated, renameType, selected);
String changed = deobfuscation.deobfuscateName(false,f.functionName, false, "function", deobfuscated, renameType, selected);
if (changed != null) {
f.replacedFunctionName = changed;
ret++;
@@ -2125,7 +2125,7 @@ public final class SWF implements TreeItem, Timelined {
for (MyEntry<DirectValueActionItem, ConstantPool> it : allVariableNames) {
vc++;
String name = it.getKey().toStringNoH(it.getValue());
String changed = deobfuscation.deobfuscateName(name, false, usageTypes.get(it.getKey()), deobfuscated, renameType, selected);
String changed = deobfuscation.deobfuscateName(false,name, false, usageTypes.get(it.getKey()), deobfuscated, renameType, selected);
if (changed != null) {
boolean addNew = false;
String h = System.identityHashCode(it.getKey()) + "_" + name;
@@ -2163,7 +2163,7 @@ public final class SWF implements TreeItem, Timelined {
src.setActions(actionsMap.get(src));
src.setModified();
}
deobfuscation.deobfuscateInstanceNames(deobfuscated, renameType, tags, selected);
deobfuscation.deobfuscateInstanceNames(false,deobfuscated, renameType, tags, selected);
return ret;
}

View File

@@ -214,7 +214,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitFunction;
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.action.Deobfuscation;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.dumpview.DumpInfo;
import com.jpexs.decompiler.flash.ecma.EcmaScript;

View File

@@ -21,7 +21,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns;
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator;
import com.jpexs.decompiler.flash.action.Deobfuscation;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
@@ -98,7 +98,7 @@ public abstract class AVM2Item extends GraphTargetItem {
public static String localRegName(HashMap<Integer, String> localRegNames, int reg) {
if (localRegNames.containsKey(reg)) {
return Deobfuscation.printIdentifier(localRegNames.get(reg));
return IdentifiersDeobfuscation.printIdentifier(true,localRegNames.get(reg));
} else {
if (reg == 0) {
return "this";

View File

@@ -260,7 +260,7 @@ public class ActionScriptParser {
s = lex();
} else {
s = lex();
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
String propName = s.value.toString();
GraphTargetItem propItem = null;
s = lex();
@@ -274,7 +274,7 @@ public class ActionScriptParser {
expectedType(SymbolType.BRACKET_CLOSE);
propName = null;
} else {
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
propName = s.value.toString();
propItem = null;
}
@@ -300,7 +300,7 @@ public class ActionScriptParser {
name += "@";
s = lex();
}
expected(s, lexer.yyline(), SymbolType.IDENTIFIER, SymbolType.THIS, SymbolType.SUPER, SymbolType.STRING_OP);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.THIS, SymbolType.SUPER, SymbolType.STRING_OP);
name += s.value.toString();
s = lex();
boolean attrBracket = false;
@@ -313,7 +313,7 @@ public class ActionScriptParser {
s = lex();
if (s.type == SymbolType.MULTIPLY) {
name += s.value.toString();
} else if (s.type == SymbolType.IDENTIFIER) {
} else if (s.group == SymbolGroup.IDENTIFIER) {
name += s.value.toString();
} else {
if (s.type != SymbolType.BRACKET_OPEN) {
@@ -323,7 +323,7 @@ public class ActionScriptParser {
continue;
}
} else {
expected(s, lexer.yyline(), SymbolType.IDENTIFIER, SymbolType.NAMESPACE);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.NAMESPACE);
name += s.value.toString();
}
s = lex();
@@ -338,7 +338,7 @@ public class ActionScriptParser {
nsname = name;
}
s = lex();
if (s.type == SymbolType.IDENTIFIER) {
if (s.group == SymbolGroup.IDENTIFIER) {
nsprop = s.value.toString();
} else if (s.type == SymbolType.BRACKET_OPEN) {
nspropItem = expression(thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);
@@ -350,27 +350,7 @@ public class ActionScriptParser {
name = null;
}
s = lex();
}
/*
List<GraphTargetItem> params = new ArrayList<>();
if (s.type == SymbolType.TYPENAME) {
s = lex();
do {
String p = "";
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
p = s.value.toString();
s = lex();
while (s.type == SymbolType.DOT) {
s = lex();
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
name += "." + s.value.toString();
s = lex();
}
params.add(p);
} while (s.type == SymbolType.COMMA);
expected(s, lexer.yyline(), SymbolType.GREATER_THAN);
s = lex();
}*/
}
GraphTargetItem ret = null;
if (name != null) {
@@ -478,7 +458,7 @@ public class ActionScriptParser {
hasRest = true;
s = lex();
}
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
paramNames.add(s.value.toString());
s = lex();
@@ -580,7 +560,7 @@ public class ActionScriptParser {
s = lex();
}
while (s.isType(SymbolType.STATIC, SymbolType.PUBLIC, SymbolType.PRIVATE, SymbolType.PROTECTED, SymbolType.OVERRIDE, SymbolType.FINAL, SymbolType.DYNAMIC, SymbolType.IDENTIFIER)) {
while (s.isType(SymbolType.STATIC, SymbolType.PUBLIC, SymbolType.PRIVATE, SymbolType.PROTECTED, SymbolType.OVERRIDE, SymbolType.FINAL, SymbolType.DYNAMIC, SymbolGroup.IDENTIFIER)) {
if (s.type == SymbolType.FINAL) {
if (isFinal) {
throw new AVM2ParseException("Only one final keyword allowed", lexer.yyline());
@@ -607,7 +587,7 @@ public class ActionScriptParser {
throw new AVM2ParseException("Only one static keyword allowed", lexer.yyline());
}
isStatic = true;
} else if (s.type == SymbolType.IDENTIFIER) {
} else if (s.group == SymbolGroup.IDENTIFIER) {
customAccess = s.value.toString();
namespace = -2;
} else {
@@ -666,7 +646,7 @@ public class ActionScriptParser {
//GraphTargetItem classTypeStr = type(thisType,pkg,needsActivation, importedClasses, openedNamespaces, variables);
s = lex();
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
String classTypeStr = s.value.toString();
GraphTargetItem extendsTypeStr = null;
s = lex();
@@ -704,7 +684,7 @@ public class ActionScriptParser {
}
//GraphTargetItem interfaceTypeStr = type(thisType,pkg,needsActivation, importedClasses, openedNamespaces, variables);
s = lex();
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
String intTypeStr = s.value.toString();
s = lex();
List<GraphTargetItem> intExtendsTypeStrs = new ArrayList<>();
@@ -744,7 +724,7 @@ public class ActionScriptParser {
s = lex();
}
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
String fname = s.value.toString();
if (classNameStr != null && fname.equals(classNameStr)) { //constructor
if (isStatic) {
@@ -803,7 +783,7 @@ public class ActionScriptParser {
throw new AVM2ParseException("Interface cannot have namespace fields", lexer.yyline());
}
s = lex();
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
String nname = s.value.toString();
String nval = "";
s = lex();
@@ -840,7 +820,7 @@ public class ActionScriptParser {
}
s = lex();
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
String vcname = s.value.toString();
s = lex();
GraphTargetItem type = null;
@@ -1194,7 +1174,7 @@ public class ActionScriptParser {
}
String loopLabel = null;
if (s.type == SymbolType.IDENTIFIER) {
if (s.group == SymbolGroup.IDENTIFIER) {
ParsedSymbol sc = lex();
if (sc.type == SymbolType.COLON) {
loopLabel = s.value.toString();
@@ -1206,7 +1186,7 @@ public class ActionScriptParser {
if (s.type == SymbolType.DEFAULT) {
ParsedSymbol sx = lex();
if (sx.type != SymbolType.IDENTIFIER) {
if (sx.group != SymbolGroup.IDENTIFIER) {
lexer.pushback(sx);
} else {
if (!sx.value.equals("xml")) {
@@ -1266,13 +1246,13 @@ public class ActionScriptParser {
break;*/
case FUNCTION:
s = lexer.lex();
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
needsActivation.setVal(true);
ret = (function(pkg, false, needsActivation, importedClasses, 0/*?*/, thisType, openedNamespaces, s.value.toString(), false, variables));
break;
case VAR:
s = lex();
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
String varIdentifier = s.value.toString();
s = lex();
GraphTargetItem type;
@@ -1480,7 +1460,7 @@ public class ActionScriptParser {
if (loops.isEmpty()) {
throw new AVM2ParseException("No loop to break", lexer.yyline());
}
if (s.type == SymbolType.IDENTIFIER) {
if (s.group == SymbolGroup.IDENTIFIER) {
String breakLabel = s.value.toString();
for (Loop l : loops) {
if (breakLabel.equals(loopLabels.get(l))) {
@@ -1503,7 +1483,7 @@ public class ActionScriptParser {
if (loops.isEmpty()) {
throw new AVM2ParseException("No loop to continue", lexer.yyline());
}
if (s.type == SymbolType.IDENTIFIER) {
if (s.group == SymbolGroup.IDENTIFIER) {
String continueLabel = s.value.toString();
for (Loop l : loops) {
if (l.id < 0) { //negative id marks switch => no continue
@@ -1553,7 +1533,7 @@ public class ActionScriptParser {
while (s.type == SymbolType.CATCH) {
expectedType(SymbolType.PARENT_OPEN);
s = lex();
expected(s, lexer.yyline(), SymbolType.IDENTIFIER, SymbolType.THIS, SymbolType.SUPER, SymbolType.STRING_OP);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.THIS, SymbolType.SUPER, SymbolType.STRING_OP);
String enamestr = s.value.toString();
expectedType(SymbolType.COLON);
@@ -1696,7 +1676,7 @@ public class ActionScriptParser {
break;
case DESCENDANTS:
ParsedSymbol d = lex();
expected(d, lexer.yyline(), SymbolType.IDENTIFIER, SymbolType.MULTIPLY);
expected(d, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.MULTIPLY);
ret = new GetDescendantsAVM2Item(expr, d.type == SymbolType.MULTIPLY ? null : d.value.toString(), openedNamespaces);
allowRemainder = true;
break;
@@ -2054,7 +2034,7 @@ public class ActionScriptParser {
lexer.pushback(s);
}
s = lex();
expected(s, lexer.yyline(), SymbolType.IDENTIFIER, SymbolType.STRING);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.STRING);
GraphTargetItem n = new StringAVM2Item(null, s.value.toString());
//expression(thisType,pkg,needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables);
@@ -2082,7 +2062,7 @@ public class ActionScriptParser {
case FUNCTION:
s = lexer.lex();
String fname = "";
if (s.isType(SymbolType.IDENTIFIER)) {
if (s.isType(SymbolGroup.IDENTIFIER)) {
fname = s.value.toString();
} else {
lexer.pushback(s);
@@ -2146,7 +2126,7 @@ public class ActionScriptParser {
if (s.type == SymbolType.FUNCTION) {
s = lexer.lex();
String ffname = "";
if (s.isType(SymbolType.IDENTIFIER)) {
if (s.isType(SymbolGroup.IDENTIFIER)) {
ffname = s.value.toString();
} else {
lexer.pushback(s);
@@ -2221,14 +2201,14 @@ public class ActionScriptParser {
String name = "";
ParsedSymbol s = lex();
if (s.type != SymbolType.CURLY_OPEN) {
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
name = s.value.toString();
s = lex();
}
while (s.type != SymbolType.CURLY_OPEN) {
expected(s, lexer.yyline(), SymbolType.DOT);
s = lex();
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
name += "." + s.value.toString();
s = lex();
}
@@ -2241,7 +2221,7 @@ public class ActionScriptParser {
String impName = null;
boolean all = false;
s = lex();
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
impName = s.value.toString();
s = lex();
while (s.type == SymbolType.DOT) {
@@ -2256,7 +2236,7 @@ public class ActionScriptParser {
s = lex();
break;
}
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
impName = s.value.toString();
s = lex();

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
/**
@@ -201,5 +202,6 @@ public enum SymbolType {
XML_INSTRATTRVALVAR_BEGIN, // aaa={
XML_INSTRVARTAG_BEGIN, // <?{
FILTER,
FILTER,
DESCENDANTS,
NATIVE
}

View File

@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException;
import com.jpexs.decompiler.flash.abc.avm2.parser.AVM2ParseException;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
@@ -29,7 +29,7 @@ import java.io.StringReader;
%unicode
%char
%type ParsedSymbol
%throws ParseException
%throws AVM2ParseException
%{
@@ -93,7 +93,7 @@ import java.io.StringReader;
informListenersPushBack(symb);
}
ParsedSymbol last;
public ParsedSymbol lex() throws java.io.IOException, ParseException{
public ParsedSymbol lex() throws java.io.IOException, AVM2ParseException{
ParsedSymbol ret=null;
if(!pushedBack.isEmpty()){
ret = last = pushedBack.pop();
@@ -212,7 +212,7 @@ OIdentifierCharacter = [^\r\n\u00A7\\]
"while" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.WHILE,yytext()); }
"else" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.ELSE,yytext()); }
"for" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.FOR,yytext()); }
"each" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.EACH,yytext()); }
"each" { return new ParsedSymbol(SymbolGroup.IDENTIFIER,SymbolType.EACH,yytext()); }
"in" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.IN,yytext()); }
"if" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.IF,yytext()); }
"return" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.RETURN,yytext()); }
@@ -224,23 +224,23 @@ OIdentifierCharacter = [^\r\n\u00A7\\]
"finally" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.FINALLY,yytext()); }
"while" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.WHILE,yytext()); }
"with" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.WITH,yytext()); }
"dynamic" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.DYNAMIC,yytext()); }
"dynamic" { return new ParsedSymbol(SymbolGroup.IDENTIFIER,SymbolType.DYNAMIC,yytext()); }
"internal" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.INTERNAL,yytext()); }
"override" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.OVERRIDE,yytext()); }
"override" { return new ParsedSymbol(SymbolGroup.IDENTIFIER,SymbolType.OVERRIDE,yytext()); }
"private" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.PRIVATE,yytext()); }
"protected" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.PROTECTED,yytext()); }
"public" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.PUBLIC,yytext()); }
"static" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.STATIC,yytext()); }
"static" { return new ParsedSymbol(SymbolGroup.IDENTIFIER,SymbolType.STATIC,yytext()); }
"class" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.CLASS,yytext()); }
"const" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.CONST,yytext()); }
"extends" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.EXTENDS,yytext()); }
"function" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.FUNCTION,yytext()); }
"get" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.GET,yytext()); }
"get" { return new ParsedSymbol(SymbolGroup.IDENTIFIER,SymbolType.GET,yytext()); }
"implements" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.IMPLEMENTS,yytext()); }
"interface" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.INTERFACE,yytext()); }
"namespace" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.NAMESPACE,yytext()); }
"namespace" { return new ParsedSymbol(SymbolGroup.IDENTIFIER,SymbolType.NAMESPACE,yytext()); }
"package" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.PACKAGE,yytext()); }
"set" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.SET,yytext()); }
"set" { return new ParsedSymbol(SymbolGroup.IDENTIFIER,SymbolType.SET,yytext()); }
"var" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.VAR,yytext()); }
"import" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.IMPORT,yytext()); }
"use" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.USE,yytext()); }
@@ -251,8 +251,8 @@ OIdentifierCharacter = [^\r\n\u00A7\\]
"undefined" { return new ParsedSymbol(SymbolGroup.GLOBALCONST,SymbolType.UNDEFINED,yytext()); }
"Infinity" { return new ParsedSymbol(SymbolGroup.GLOBALCONST,SymbolType.INFINITY,yytext()); }
"NaN" { return new ParsedSymbol(SymbolGroup.GLOBALCONST,SymbolType.NAN,yytext()); }
"final" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.FINAL,yytext()); }
"final" { return new ParsedSymbol(SymbolGroup.IDENTIFIER,SymbolType.FINAL,yytext()); }
"native" { return new ParsedSymbol(SymbolGroup.IDENTIFIER,SymbolType.NATIVE,yytext()); }
/* operators */
@@ -584,7 +584,7 @@ OIdentifierCharacter = [^\r\n\u00A7\\]
/* escape sequences */
\\. { throw new ParseException("Illegal escape sequence \""+yytext()+"\"",yyline+1); }
\\. { throw new AVM2ParseException("Illegal escape sequence \""+yytext()+"\"",yyline+1); }
{LineTerminator} { yybegin(YYINITIAL); yyline++;}
}
@@ -611,7 +611,7 @@ OIdentifierCharacter = [^\r\n\u00A7\\]
/* escape sequences */
\\. { throw new ParseException("Illegal escape sequence \""+yytext()+"\"",yyline+1); }
\\. { throw new AVM2ParseException("Illegal escape sequence \""+yytext()+"\"",yyline+1); }
{LineTerminator} { yybegin(YYINITIAL); yyline++;}
}
@@ -639,7 +639,7 @@ OIdentifierCharacter = [^\r\n\u00A7\\]
/* escape sequences */
\\. { throw new ParseException("Illegal escape sequence \""+yytext()+"\"",yyline+1); }
\\. { throw new AVM2ParseException("Illegal escape sequence \""+yytext()+"\"",yyline+1); }
{LineTerminator} { yybegin(YYINITIAL); yyline++;}
}

View File

@@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewFunctionIns;
import com.jpexs.decompiler.flash.action.Deobfuscation;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.helpers.Helper;
@@ -283,9 +283,9 @@ public class MethodInfo {
pdata.put("regIndex", ""+(i+1));
if (!localRegNames.isEmpty()) {
pdata.put("slotName", localRegNames.get(i + 1)); //assuming it is a slot
writer.hilightSpecial(Deobfuscation.printIdentifier(localRegNames.get(i + 1)),"paramname",i,pdata);
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true,localRegNames.get(i + 1)),"paramname",i,pdata);
} else if ((paramNames.length > i) && (paramNames[i] != 0) && Configuration.paramNamesEnable.get()) {
writer.hilightSpecial(Deobfuscation.printIdentifier(constants.getString(paramNames[i])),"paramname",i,pdata);
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true,constants.getString(paramNames[i])),"paramname",i,pdata);
} else {
writer.hilightSpecial("param" + (i + 1),"paramname",i,pdata);
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.types;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.action.Deobfuscation;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.helpers.Helper;
import java.util.List;
@@ -264,7 +264,7 @@ public class Multiname {
if ((fullyQualifiedNames != null) && fullyQualifiedNames.contains(name)) {
return getNameWithNamespace(constants, raw);
}
return (isAttribute() ? "@" : "") + (raw ? name : Deobfuscation.printIdentifier(name));
return (isAttribute() ? "@" : "") + (raw ? name : IdentifiersDeobfuscation.printIdentifier(true,name));
}
}

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.action.Deobfuscation;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
public class Namespace {
@@ -104,7 +104,7 @@ public class Namespace {
if (raw) {
return constants.getString(name_index);
}
return Deobfuscation.printNamespace(constants.getString(name_index));
return IdentifiersDeobfuscation.printNamespace(true,constants.getString(name_index));
}
public boolean hasName(String name, AVM2ConstantPool constants) {

View File

@@ -103,28 +103,7 @@ public class Action implements GraphSourceItem {
* Length of action data
*/
public int actionLength;
private long address;
public static final String[] reservedWords = {
"as", "break", "case", "catch", "class", "const", "continue", "default", "delete", "do", "else",
"extends", "false", "finally", "for", "function", "if", "implements", "import", "in", "instanceof",
"interface", "internal", "is", "native", "new", "null", "package", "private", "protected", "public",
"return", "super", "switch", "this", "throw",/*to*/ "true", "try", "typeof", "use", "var", /*"void",*/ "while",
"with",
//syntactic keywords - can be used as identifiers, but that have special meaning in certain contexts
"each", "get", "set", "namespace", "#include", "include", "dynamic", "final", "native", "override", "static", "in"};
public static boolean isReservedWord(String s) {
if (s == null) {
return false;
}
for (String rw : reservedWords) {
if (rw.equals(s.trim())) {
return true;
}
}
return false;
}
private long address;
/**
* Names of ActionScript properties

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.Deobfuscation;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.action.swf5.ActionCallFunction;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
@@ -49,7 +49,7 @@ public class CallFunctionActionItem extends ActionItem {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
String paramStr = "";
writer.append(Deobfuscation.printIdentifier(((DirectValueActionItem) functionName).toStringNoQuotes(localData)));
writer.append(IdentifiersDeobfuscation.printIdentifier(false,((DirectValueActionItem) functionName).toStringNoQuotes(localData)));
writer.spaceBeforeCallParenthesies(arguments.size());
writer.append("(");
for (int t = 0; t < arguments.size(); t++) {

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.Deobfuscation;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.action.swf5.ActionCallMethod;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -73,7 +73,7 @@ public class CallMethodActionItem extends ActionItem {
scriptObject.toString(writer, localData);
}
writer.append(".");
writer.append(Deobfuscation.printIdentifier(methodName.toStringNoQuotes(localData)));
writer.append(IdentifiersDeobfuscation.printIdentifier(false,methodName.toStringNoQuotes(localData)));
} else {
scriptObject.toString(writer, localData);
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.Deobfuscation;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal;
import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal2;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -76,8 +76,8 @@ public class DefineLocalActionItem extends ActionItem implements SetTypeActionIt
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.append("var ");
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!Deobfuscation.isValidName(((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
writer.append(Deobfuscation.makeObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData)));
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false,((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
writer.append(IdentifiersDeobfuscation.makeObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData)));
} else {
stripQuotes(name, localData, writer);
}

View File

@@ -12,13 +12,14 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
@@ -82,15 +83,15 @@ public class FunctionActionItem extends ActionItem {
if (calculatedFunctionName != null) {
writer.append(" ");
String fname = calculatedFunctionName.toStringNoQuotes(localData);
String fname = calculatedFunctionName.toStringNoQuotes(localData);
if (!Deobfuscation.isValidName(fname)) {
if (!IdentifiersDeobfuscation.isValidName(false,fname)) {
writer.append(IdentifiersDeobfuscation.makeObfuscatedIdentifier(fname));
} else {
calculatedFunctionName.appendToNoQuotes(writer, localData);
}
} else if (!functionName.isEmpty()) {
writer.append(" ");
writer.append(" ");
if (!Deobfuscation.isValidName(functionName)) {
if (!IdentifiersDeobfuscation.isValidName(false,functionName)) {
writer.append(IdentifiersDeobfuscation.makeObfuscatedIdentifier(functionName));
} else {
writer.append(functionName);
}
@@ -106,8 +107,8 @@ public class FunctionActionItem extends ActionItem {
if (pname == null || pname.isEmpty()) {
pname = new RegisterNumber(regStart + p).translate();
}
}
if (!Deobfuscation.isValidName(pname)) {
if (!IdentifiersDeobfuscation.isValidName(false,pname)) {
writer.append(IdentifiersDeobfuscation.makeObfuscatedIdentifier(pname));
}
writer.append(pname);
}

View File

@@ -12,11 +12,12 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.action.swf5.ActionGetMember;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
@@ -49,7 +50,7 @@ public class GetMemberActionItem extends ActionItem {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
object.toString(writer, localData);
object.toString(writer, localData);
if ((!(memberName instanceof DirectValueActionItem)) || (!((DirectValueActionItem) memberName).isString()) || (!IdentifiersDeobfuscation.isValidName(false,((DirectValueActionItem) memberName).toStringNoQuotes(localData)))) {
writer.append("[");
memberName.toString(writer, localData);
return writer.append("]");

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.Deobfuscation;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -59,8 +59,8 @@ public class GetVariableActionItem extends ActionItem {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!Deobfuscation.isValidName(((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
return writer.append(Deobfuscation.makeObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData)));
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false,((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
return writer.append(IdentifiersDeobfuscation.makeObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData)));
} else if ((!(name instanceof DirectValueActionItem)) || (!((DirectValueActionItem) name).isString())) {
writer.append("eval(");
name.appendTo(writer, localData);

View File

@@ -12,11 +12,12 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
@@ -84,7 +85,7 @@ public class SetMemberActionItem extends ActionItem implements SetTypeActionItem
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
object.toString(writer, localData);
if ((!(objectName instanceof DirectValueActionItem)) || (!((DirectValueActionItem) objectName).isString()) || (!IdentifiersDeobfuscation.isValidName(false,((DirectValueActionItem) objectName).toStringNoQuotes(localData)))) {
writer.append("[");
objectName.toString(writer, localData);
writer.append("]");

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.Deobfuscation;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.action.swf4.ActionSetVariable;
@@ -73,8 +73,8 @@ public class SetVariableActionItem extends ActionItem implements SetTypeActionIt
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!Deobfuscation.isValidName(((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
writer.append(Deobfuscation.makeObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData)));
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false,((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
writer.append(IdentifiersDeobfuscation.makeObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData)));
writer.append(" = ");
return value.toString(writer, localData);
} else if ((!(name instanceof DirectValueActionItem)) || (!((DirectValueActionItem) name).isString())) {