-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8321156: Improve the handling of invalid UTF-8 byte sequences for ZipInputStream::getNextEntry and ZipFile::getComment #17995
Conversation
👋 Welcome back lancea! A progress list of the required criteria for merging this PR into |
@LanceAndersen The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comment on the code changes and the test. Some may be a matter of preference.
test/jdk/java/util/zip/ZipFile/InvalidBytesInEntryNameOrComment.java
Outdated
Show resolved
Hide resolved
test/jdk/java/util/zip/ZipFile/InvalidBytesInEntryNameOrComment.java
Outdated
Show resolved
Hide resolved
test/jdk/java/util/zip/ZipFile/InvalidBytesInEntryNameOrComment.java
Outdated
Show resolved
Hide resolved
test/jdk/java/util/zip/ZipFile/InvalidBytesInEntryNameOrComment.java
Outdated
Show resolved
Hide resolved
Since the CSR is already approved, I'll add a question here:
Do we have reason to belive the encoding quality of ZIP file comments is less reliable than that of ZIP entry comments? Or is there some other reason this validation is done lazily? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your input Eirik, I have pushed updates to address the suggestions you raised
test/jdk/java/util/zip/ZipFile/InvalidBytesInEntryNameOrComment.java
Outdated
Show resolved
Hide resolved
test/jdk/java/util/zip/ZipFile/InvalidBytesInEntryNameOrComment.java
Outdated
Show resolved
Hide resolved
test/jdk/java/util/zip/ZipFile/InvalidBytesInEntryNameOrComment.java
Outdated
Show resolved
Hide resolved
test/jdk/java/util/zip/ZipFile/InvalidBytesInEntryNameOrComment.java
Outdated
Show resolved
Hide resolved
test/jdk/java/util/zip/ZipFile/InvalidBytesInEntryNameOrComment.java
Outdated
Show resolved
Hide resolved
Yes, there are some libraries/tools that are using the Zip file comment for its own purposes such as idea_rt.jar which is part of IntelliJ. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello Lance, the changes look fine to me. ZipFile.java
file will need a copyright year update.
@LanceAndersen This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 3 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
test/jdk/java/util/zip/ZipFile/InvalidBytesInEntryNameOrComment.java
Outdated
Show resolved
Hide resolved
} catch(Exception ex) { | ||
throw (ZipException) new ZipException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace nit:
} catch(Exception ex) { | |
throw (ZipException) new ZipException( | |
} catch (Exception ex) { | |
throw (ZipException) new ZipException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. Updated accordingly
} catch(Exception ex) { | ||
throw (ZipException) new ZipException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
test/jdk/java/util/zip/ZipFile/InvalidBytesInEntryNameOrComment.java
Outdated
Show resolved
Hide resolved
Thank you Jai, updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the updates, Lance. The changes look good to me.
* Returns the zip file comment, or null if none. | ||
* Returns the zip file comment. If a comment does not exist or an error is | ||
* encountered decoding the comment using the charset specified | ||
* when opening the Zip file, then {@code null} is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've previously discussed options with Lance around this issue and I agree with the proposal to specify that it returns null when the decoding fails.
(In passing, the casing of "zip file" is very inconsistent in the javadoc, it's "ZIP file" in some places, "zip file" in others, the change here uses "Zip file").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(In passing, the casing of "zip file" is very inconsistent in the javadoc, it's "ZIP file" in some places, "zip file" in others, the change here uses "Zip file").
Thank you for pointing out the discrepancy above.
Let's decide on which way to go and I will update under a separate PR.
I would suggest "ZIP file" based on the PKWare APPNOTE.TXT, but the man pages for info-zip command zip command uses "zip file"
Apache commons also uses "ZIP file" or "ZIP archive"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest "ZIP file" based on the PKWare APPNOTE.TXT,
I think using this case would be good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest "ZIP file" based on the PKWare APPNOTE.TXT, but the man pages for info-zip command zip command uses "zip file"
"ZIP" is not an acronym so I assume this is why they use "zip" in their docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spec + implementation change look fine. I haven't spent time looking at the test.
/integrate |
1 similar comment
/integrate |
Going to push as commit 20c71ce.
Your commit was automatically rebased without conflicts. |
@LanceAndersen Pushed as commit 20c71ce. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
@LanceAndersen The command |
Please review this PR which addresses the handling of invalid UTF-8 byte sequences in the entry name of a LOC file header and a Zip file comment which is returned via ZipFile::getComment.
As part of the change,
ZipFile::getComment
will now returnnull
if an invalid UTF-8 byte sequence is encountered while converting the byte array to a String. The CSR for this change has also been approved.Mach5 tiers 1-3 are clean with this change.
Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17995/head:pull/17995
$ git checkout pull/17995
Update a local copy of the PR:
$ git checkout pull/17995
$ git pull https://git.openjdk.org/jdk.git pull/17995/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17995
View PR using the GUI difftool:
$ git pr show -t 17995
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17995.diff
Webrev
Link to Webrev Comment