Skip to content
Permalink
Browse files
8276123: ZipFile::getEntry will not return a file entry when there is…
… a directory entry of the same name within a Zip File

Reviewed-by: redestad, alanb
  • Loading branch information
Lance Andersen committed Nov 12, 2021
1 parent 0d2980c commit b85500e52479c48b02a96b28fddefa2b25d5d9bd
Showing 2 changed files with 591 additions and 5 deletions.
@@ -1631,13 +1631,18 @@ private int getEntryPos(String name, boolean addSlash) {
// slash
int entryLen = entry.length();
int nameLen = name.length();
if ((entryLen == nameLen && entry.equals(name)) ||
(addSlash &&
nameLen + 1 == entryLen &&
entry.startsWith(name) &&
entry.charAt(entryLen - 1) == '/')) {
if (entryLen == nameLen && entry.equals(name)) {
// Found our match
return pos;
}
// If addSlash is true we'll now test for name+/ providing
if (addSlash && nameLen + 1 == entryLen
&& entry.startsWith(name) &&
entry.charAt(entryLen - 1) == '/') {
// Found the entry "name+/", now find the CEN entry pos
int exactPos = getEntryPos(name, false);
return exactPos == -1 ? pos : exactPos;
}
} catch (IllegalArgumentException iae) {
// Ignore
}

1 comment on commit b85500e

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on b85500e Nov 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.