mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
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
This commit is contained in:
parent
0d2980cdd1
commit
b85500e524
2 changed files with 591 additions and 5 deletions
|
@ -1631,13 +1631,18 @@ public class ZipFile implements ZipConstants, Closeable {
|
|||
// 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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue