Skip to content

Commit

Permalink
Address odd edge case where some discovered 'zip' files aren't zips. …
Browse files Browse the repository at this point in the history
…Mostly useful for not killing workspace reading when looking at embedded files.
  • Loading branch information
Col-E committed Apr 27, 2024
1 parent 0d632a8 commit d92a543
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,17 @@ private WorkspaceFileResource handleZip(WorkspaceFileResourceBuilder builder, Zi
NavigableMap<Integer, JvmClassBundle> versionedJvmClassBundles = new TreeMap<>();
Map<String, WorkspaceFileResource> embeddedResources = new HashMap<>();

// Read ZIP entries
// Read ZIP
boolean isAndroid = zipInfo.getName().toLowerCase().endsWith(".apk");
ZipArchive archive = config.mapping().apply(source.readAll());

// Sanity check, if there's data at the head of the file AND its otherwise empty its probably junk.
if (archive.getPrefixData() != null && archive.getEnd() != null && archive.getParts().size() == 1) {
// We'll throw as the caller should catch this case and handle it based on their needs.
throw new IOException("Content matched ZIP header but had no file entries");
}

// Build model from the contained files in the ZIP
archive.getLocalFiles().forEach(header -> {
LocalFileHeaderSource headerSource = new LocalFileHeaderSource(header, isAndroid);
String entryName = header.getFileNameAsString();
Expand Down

0 comments on commit d92a543

Please sign in to comment.