mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-24 17:34:33 +00:00
ignore invalid tags in test (do not use lazy loading in tests)
This commit is contained in:
@@ -745,7 +745,20 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, boolean parallelRead) throws IOException, InterruptedException {
|
||||
this(is, null, null, null, parallelRead, false);
|
||||
this(is, null, null, null, parallelRead, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct SWF from stream
|
||||
*
|
||||
* @param is Stream to read SWF from
|
||||
* @param parallelRead Use parallel threads?
|
||||
* @param lazy
|
||||
* @throws IOException
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, boolean parallelRead, boolean lazy) throws IOException, InterruptedException {
|
||||
this(is, null, null, null, parallelRead, false, lazy);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -759,7 +772,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, String file, String fileTitle, boolean parallelRead) throws IOException, InterruptedException {
|
||||
this(is, file, fileTitle, null, parallelRead, false);
|
||||
this(is, file, fileTitle, null, parallelRead, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -772,7 +785,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, ProgressListener listener, boolean parallelRead) throws IOException, InterruptedException {
|
||||
this(is, null, null, listener, parallelRead, false);
|
||||
this(is, null, null, listener, parallelRead, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -787,7 +800,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead) throws IOException, InterruptedException {
|
||||
this(is, file, fileTitle, listener, parallelRead, false);
|
||||
this(is, file, fileTitle, listener, parallelRead, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -809,10 +822,11 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* @param listener
|
||||
* @param parallelRead Use parallel threads?
|
||||
* @param checkOnly Check only file validity
|
||||
* @param lazy
|
||||
* @throws IOException
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead, boolean checkOnly) throws IOException, InterruptedException {
|
||||
public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead, boolean checkOnly, boolean lazy) throws IOException, InterruptedException {
|
||||
this.file = file;
|
||||
this.fileTitle = fileTitle;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
@@ -839,7 +853,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
sis.readUI8("tmpFirstByetOfFrameRate"); // tmpFirstByetOfFrameRate
|
||||
frameRate = sis.readUI8("frameRate");
|
||||
frameCount = sis.readUI16("frameCount");
|
||||
List<Tag> tags = sis.readTagList(this, 0, parallelRead, true, !checkOnly);
|
||||
List<Tag> tags = sis.readTagList(this, 0, parallelRead, true, !checkOnly, lazy);
|
||||
if (tags.size() > 0 && tags.get(tags.size() - 1).getId() == EndTag.ID) {
|
||||
tags.remove(tags.size() - 1);
|
||||
} else {
|
||||
|
||||
@@ -1017,19 +1017,22 @@ public class SWFInputStream implements AutoCloseable {
|
||||
|
||||
private final boolean skipUnusualTags;
|
||||
|
||||
public TagResolutionTask(TagStub tag, DumpInfo dumpInfo, int level, boolean parallel, boolean skipUnusualTags) {
|
||||
private final boolean lazy;
|
||||
|
||||
public TagResolutionTask(TagStub tag, DumpInfo dumpInfo, int level, boolean parallel, boolean skipUnusualTags, boolean lazy) {
|
||||
this.tag = tag;
|
||||
this.dumpInfo = dumpInfo;
|
||||
this.level = level;
|
||||
this.parallel = parallel;
|
||||
this.skipUnusualTags = skipUnusualTags;
|
||||
this.lazy = lazy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag call() throws Exception {
|
||||
DumpInfo di = dumpInfo;
|
||||
try {
|
||||
Tag t = resolveTag(tag, level, parallel, skipUnusualTags, true);
|
||||
Tag t = resolveTag(tag, level, parallel, skipUnusualTags, lazy);
|
||||
if (dumpInfo != null && t != null) {
|
||||
dumpInfo.name = t.getName();
|
||||
}
|
||||
@@ -1051,11 +1054,12 @@ public class SWFInputStream implements AutoCloseable {
|
||||
* @param parallel
|
||||
* @param skipUnusualTags
|
||||
* @param parseTags
|
||||
* @param lazy
|
||||
* @return List of tags
|
||||
* @throws IOException
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public List<Tag> readTagList(Timelined timelined, int level, boolean parallel, boolean skipUnusualTags, boolean parseTags) throws IOException, InterruptedException {
|
||||
public List<Tag> readTagList(Timelined timelined, int level, boolean parallel, boolean skipUnusualTags, boolean parseTags, boolean lazy) throws IOException, InterruptedException {
|
||||
boolean parallel1 = level == 0 && parallel;
|
||||
ExecutorService executor = null;
|
||||
List<Future<Tag>> futureResults = new ArrayList<>();
|
||||
@@ -1070,7 +1074,7 @@ public class SWFInputStream implements AutoCloseable {
|
||||
long pos = getPos();
|
||||
newDumpLevel(null, "TAG");
|
||||
try {
|
||||
tag = readTag(timelined, level, pos, parseTags && !parallel1, parallel1, skipUnusualTags);
|
||||
tag = readTag(timelined, level, pos, parseTags && !parallel1, parallel1, skipUnusualTags, lazy);
|
||||
} catch (EOFException | EndOfStreamException ex) {
|
||||
tag = null;
|
||||
}
|
||||
@@ -1098,7 +1102,7 @@ public class SWFInputStream implements AutoCloseable {
|
||||
switch (tag.getId()) {
|
||||
case FileAttributesTag.ID: // FileAttributes
|
||||
if (tag instanceof TagStub) {
|
||||
tag = resolveTag((TagStub) tag, level, parallel1, skipUnusualTags, true);
|
||||
tag = resolveTag((TagStub) tag, level, parallel1, skipUnusualTags, lazy);
|
||||
}
|
||||
FileAttributesTag fileAttributes = (FileAttributesTag) tag;
|
||||
if (fileAttributes.actionScript3) {
|
||||
@@ -1140,7 +1144,7 @@ public class SWFInputStream implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
if (parseTags && doParse && parallel1 && tag instanceof TagStub) {
|
||||
Future<Tag> future = executor.submit(new TagResolutionTask((TagStub) tag, di, level, parallel1, skipUnusualTags));
|
||||
Future<Tag> future = executor.submit(new TagResolutionTask((TagStub) tag, di, level, parallel1, skipUnusualTags, lazy));
|
||||
futureResults.add(future);
|
||||
} else {
|
||||
Future<Tag> future = new ImmediateFuture<>(tag);
|
||||
@@ -1472,11 +1476,12 @@ public class SWFInputStream implements AutoCloseable {
|
||||
* @param resolve
|
||||
* @param parallel
|
||||
* @param skipUnusualTags
|
||||
* @param lazy
|
||||
* @return Tag or null when End tag
|
||||
* @throws IOException
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public Tag readTag(Timelined timelined, int level, long pos, boolean resolve, boolean parallel, boolean skipUnusualTags) throws IOException, InterruptedException {
|
||||
public Tag readTag(Timelined timelined, int level, long pos, boolean resolve, boolean parallel, boolean skipUnusualTags, boolean lazy) throws IOException, InterruptedException {
|
||||
int tagIDTagLength = readUI16("tagIDTagLength");
|
||||
int tagID = (tagIDTagLength) >> 6;
|
||||
|
||||
@@ -1509,7 +1514,7 @@ public class SWFInputStream implements AutoCloseable {
|
||||
if (resolve) {
|
||||
DumpInfo di = dumpInfo;
|
||||
try {
|
||||
ret = resolveTag(tagStub, level, parallel, skipUnusualTags, true);
|
||||
ret = resolveTag(tagStub, level, parallel, skipUnusualTags, lazy);
|
||||
} catch (Exception ex) {
|
||||
tagDataStream.endDumpLevelUntil(di);
|
||||
logger.log(Level.SEVERE, "Problem in " + timelined.toString(), ex);
|
||||
|
||||
@@ -90,7 +90,7 @@ public class SWFSearch {
|
||||
MemoryInputStream mis = (MemoryInputStream) ret.get(addr);
|
||||
mis.reset();
|
||||
PosMarkedInputStream pmi = new PosMarkedInputStream(mis);
|
||||
SWF swf = noCheck ? new SWF(pmi) : new SWF(pmi, null, null, null, false, true);
|
||||
SWF swf = noCheck ? new SWF(pmi) : new SWF(pmi, null, null, null, false, true, true);
|
||||
boolean valid = swf.fileSize > 0
|
||||
&& swf.version > 0
|
||||
&& (!swf.tags.isEmpty() || noCheck)
|
||||
|
||||
@@ -225,7 +225,7 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli
|
||||
public final void readData(SWFInputStream sis, ByteArrayRange data, int level, boolean parallel, boolean skipUnusualTags, boolean lazy) throws IOException, InterruptedException {
|
||||
spriteId = sis.readUI16("spriteId");
|
||||
frameCount = sis.readUI16("frameCount");
|
||||
List<Tag> subTags = sis.readTagList(this, level + 1, parallel, skipUnusualTags, true);
|
||||
List<Tag> subTags = sis.readTagList(this, level + 1, parallel, skipUnusualTags, true, lazy);
|
||||
if (subTags.size() > 0 && subTags.get(subTags.size() - 1).getId() == EndTag.ID) {
|
||||
hasEndTag = true;
|
||||
subTags.remove(subTags.size() - 1);
|
||||
|
||||
Reference in New Issue
Block a user