Fixed: SymbolClass export/import did not support obfuscated names

This commit is contained in:
Jindra Petřík
2025-07-27 14:35:26 +02:00
parent e65a19fd15
commit 8f11f043ca
8 changed files with 936 additions and 8 deletions
@@ -72,12 +72,12 @@ public class SymbolClassExporter {
if (t instanceof ExportAssetsTag) {
ExportAssetsTag eat = (ExportAssetsTag) t;
for (int i = 0; i < eat.tags.size(); i++) {
writer.append(eat.tags.get(i) + ";" + eat.names.get(i) + Helper.newLine);
writer.append(eat.tags.get(i) + ";\"" + Helper.escapePCodeString(eat.names.get(i)).replace("\"", "\"\"") + "\"" + Helper.newLine);
}
} else if (t instanceof SymbolClassTag) {
SymbolClassTag sct = (SymbolClassTag) t;
for (int i = 0; i < sct.tags.size(); i++) {
writer.append(sct.tags.get(i) + ";" + sct.names.get(i) + Helper.newLine);
writer.append(sct.tags.get(i) + ";\"" + Helper.escapePCodeString(sct.names.get(i)).replace("\"", "\"\"") + "\"" + Helper.newLine);
}
}
if (CancellableWorker.isInterrupted()) {
@@ -16,14 +16,19 @@
*/
package com.jpexs.decompiler.flash.importers;
import com.jpexs.csv.CsvLexer;
import com.jpexs.csv.CsvRow;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
import com.jpexs.decompiler.flash.tags.SymbolClassTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.helpers.Helper;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* SymbolClass importer.
@@ -34,18 +39,31 @@ public class SymbolClassImporter {
/**
* Imports SymbolClasses from a file.
*
* @param importFile File to import from
* @param swf SWF to import to
*/
public void importSymbolClasses(File importFile, SWF swf) {
String texts = Helper.readTextFile(importFile.getPath());
String[] lines = texts.split(Helper.newLine);
CsvLexer lexer = new CsvLexer(texts);
Map<Integer, String> nameMap = new HashMap<>();
for (String line : lines) {
String[] pair = line.split(";");
int characterId = Integer.parseInt(pair[0]);
String name = pair[1];
nameMap.put(characterId, name);
try {
while (true) {
CsvRow row = lexer.yylex();
if (row == null) {
break;
}
if (row.values.size() >= 2) {
try {
nameMap.put(Integer.parseInt(row.values.get(0)), row.values.get(1));
} catch (NumberFormatException nfe) {
//ignore
}
}
}
} catch (IOException ex) {
//ignore
}
for (Tag tag : swf.getTags()) {