Don't duplicate META-INF entries in nested directory jars

Update `ZipContent` so that `META-INF` entries are no longer duplicated
in nested jars created from directory entries. This aligns with the
behavior of the classic loader and prevents the same META-INF file from
being discovered twice.

Fixes gh-38862
This commit is contained in:
Phillip Webb
2023-12-20 17:36:06 -08:00
parent b2185282d4
commit f31ffbf927
3 changed files with 7 additions and 14 deletions

View File

@@ -637,10 +637,7 @@ public final class ZipContent implements Closeable {
.load(zip.data, pos);
long namePos = pos + ZipCentralDirectoryFileHeaderRecord.FILE_NAME_OFFSET;
short nameLen = centralRecord.fileNameLength();
if (ZipString.startsWith(loader.buffer, zip.data, namePos, nameLen, META_INF) != -1) {
loader.add(centralRecord, pos, false);
}
else if (ZipString.startsWith(loader.buffer, zip.data, namePos, nameLen, directoryName) != -1) {
if (ZipString.startsWith(loader.buffer, zip.data, namePos, nameLen, directoryName) != -1) {
loader.add(centralRecord, pos, true);
}
}