import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
* into memory, and don't close (since POI 4.0.1) the source stream.
* We'll then eat lots of memory, but be able to
* work with the entries at-will.
+ * @throws IOException if an error occurs while reading the zip entries
+ * @throws InvalidZipException if the input file contains an entry with an empty name or more than 1 entry with the same name
* @see #setThresholdBytesForTempFiles
*/
public ZipInputStreamZipEntrySource(ZipArchiveThresholdInputStream inp) throws IOException {
break;
}
String name = zipEntry.getName();
+ if (name == null || name.isEmpty()) {
+ throw new InvalidZipException("Input file contains an entry with an empty name");
+ }
+ name = name.toLowerCase(Locale.ROOT);
if (filenames.contains(name)) {
- throw new InvalidZipException("Input file contains more than 1 entry with the name " + name);
+ throw new InvalidZipException("Input file contains more than 1 entry with the name " + zipEntry.getName());
}
filenames.add(name);
zipEntries.put(name, new ZipArchiveFakeEntry(zipEntry, inp));
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashSet;
+import java.util.Locale;
import java.util.Set;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
final Enumeration<ZipArchiveEntry> en = getEntries();
final Set<String> filenames = new HashSet<>();
while (en.hasMoreElements()) {
- String name = en.nextElement().getName();
+ final ZipArchiveEntry entry = en.nextElement();
+ String name = entry.getName();
+ if (name == null || name.isEmpty()) {
+ throw new InvalidZipException("Input file contains an entry with an empty name");
+ }
+ name = name.toLowerCase(Locale.ROOT);
if (filenames.contains(name)) {
- throw new InvalidZipException("Input file contains more than 1 entry with the name " + name);
+ throw new InvalidZipException("Input file contains more than 1 entry with the name " + entry.getName());
}
filenames.add(name);
}