Re: [PR] Fix temporary file leak in ZipInputStreamZipEntrySo urce on constructor failure [poi]
pjfanning (via GitHub) <[email protected]>
| Newsgroups | gmane.comp.jakarta.poi.devel |
|---|---|
| Message-ID | <PR_kwDOAAMmIM7k-F94-6710c55c-160e-4c59-ba99-b3b7ad89d5d6@gitbox.apache.org> |
pjfanning commented on code in PR #1128:
URL: https://github.com/apache/poi/pull/1128#discussion_r3390364783
##########
poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java:
##########
@@ -98,21 +97,33 @@ public static boolean shouldEncryptTempFiles() {
*/
public ZipInputStreamZipEntrySource(ZipArchiveThresholdInputStream inp) throws IOException {
final Set<String> filenames = new HashSet<>();
- for (;;) {
- final ZipArchiveEntry zipEntry = inp.getNextEntry();
- if (zipEntry == null) {
- break;
+ try {
+ for (;;) {
+ final ZipArchiveEntry zipEntry = inp.getNextEntry();
+ if (zipEntry == null) {
+ break;
+ }
+ String name = zipEntry.getName();
+ if (name == null || name.isEmpty()) {
+ throw new InvalidZipException("Input file contains an entry with an empty name");
+ }
+ name = name.replace('\\', '/').toLowerCase(Locale.ROOT);
Review Comment:
use IOUtils.normalizePath
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]