refactor: Remove ZipFileData fields#790
Conversation
There was a problem hiding this comment.
The PR removes three redundant fields (encrypted, is_utf8, using_data_descriptor) from ZipFileData and replaces them with computed methods. The changes appear functionally correct with no logic errors or security issues. However, the PR title "Remove zipfiledata fields" does not conform to the Conventional Commits format required by the repository guidelines. The title should start with a type prefix like refactor:, fix:, feat:, etc. Consider updating it to something like: refactor: remove redundant fields from ZipFileData
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
ZipFileData fields
There was a problem hiding this comment.
Code Review
This pull request bumps the crate version to 9.0.0 and refactors the ZipFileData struct by removing the redundant encrypted, is_utf8, and using_data_descriptor boolean fields, instead deriving these states directly from the flags bitfield. Helper methods were introduced to maintain the API, and all call sites have been updated accordingly. Review feedback identified a logic error in the flags() method that causes data loss by discarding existing bits in the flags field, as well as a redundant UTF-8 check during file initialization.
| if std::str::from_utf8(&file_name_raw).is_ok() && !file_name.is_ascii() { | ||
| flags |= ZipFlags::LanguageEncoding.as_u16(); | ||
| } |
There was a problem hiding this comment.
The check std::str::from_utf8(&file_name_raw).is_ok() is redundant here. file_name_raw is created directly from file_name.as_bytes() on line 428, and since file_name is a Box, it is guaranteed to be valid UTF-8.
| if std::str::from_utf8(&file_name_raw).is_ok() && !file_name.is_ascii() { | |
| flags |= ZipFlags::LanguageEncoding.as_u16(); | |
| } | |
| if !file_name.is_ascii() { | |
| flags |= ZipFlags::LanguageEncoding.as_u16(); | |
| } |
There was a problem hiding this comment.
Yes but later the file_name could be not UTF-8
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
Pr0methean
left a comment
There was a problem hiding this comment.
Mostly looks good, but please address the remaining Gemini suggestion.
I don't think gemini i really correct here
Imploding -> we cannot compress with imploding with the current crate (decompress only) |
I don't really know the
is_asciicheckea30849#diff-ed12f5ea605f23bb4d26cc65778e3daff9db3eec40e2abfc82beafca130a99a0