Skip to content

fix: rewrite extra fields#879

Open
Its-Just-Nans wants to merge 122 commits into
masterfrom
rewrite-extra-fields
Open

fix: rewrite extra fields#879
Its-Just-Nans wants to merge 122 commits into
masterfrom
rewrite-extra-fields

Conversation

@Its-Just-Nans

@Its-Just-Nans Its-Just-Nans commented Jul 8, 2026

Copy link
Copy Markdown
Member

Second part of the extra fields rewrite

Big change is that ExtraFields are now structs, not random Vec<u8>

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR successfully refactors extra fields from raw byte vectors to structured types, improving type safety and maintainability. The changes correctly preserve functionality while making the codebase more robust. The refactoring includes:

  • Replacing #[repr(packed, C)] with proper typed structs in AexEncryption
  • Improving Zip64ExtendedInformation::parse to handle u32/u64 conversions correctly
  • Adding write methods for UnicodeExtraField
  • Creating a new structured ExtraField enum

No blocking issues found. The code is ready for merge once the draft status is resolved and the mentioned tests are fixed.


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.

Comment thread src/write.rs Fixed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the handling of ZIP extra fields by replacing raw byte arrays with a structured ExtraFields type and ExtraField enum, updating both the reader and writer implementations to parse, apply, and serialize these fields directly. The review feedback highlights several critical areas for improvement: a potential infinite loop/DoS vulnerability in stream reading on Io errors, unnecessary heap allocations when skipping bytes, robustness issues when parsing invalid UTF-8 in Unicode comments or paths, and multiple uses of unstable let-chains that could break MSRV compatibility. Additionally, a breaking change was identified in ZipFile::extra_data where it returns empty vectors instead of None, and some commented-out code needs to be cleaned up.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/read/stream.rs Outdated
Comment thread src/extra_fields/extra_field.rs Outdated
Comment thread src/extra_fields/extra_field.rs
Comment thread src/extra_fields/extra_field.rs Outdated
Comment thread src/extra_fields/extra_field.rs Outdated
Comment thread src/read/zipfile.rs
Comment thread src/write.rs Outdated
Comment thread src/write.rs Outdated
Comment thread src/write.rs
@Its-Just-Nans Its-Just-Nans changed the title Rewrite extra fields fix: rewrite extra fields Jul 8, 2026
Comment thread .gitignore
@Pr0methean

Copy link
Copy Markdown
Member

I've started to review this version of the PR, and will likely be able to finish in the next few days.

@Pr0methean Pr0methean left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a partial review; it covers all except src/write.rs and tests/*.rs.

Comment thread src/extra_fields/extra_field.rs Outdated
Comment thread src/read/stream.rs
Comment thread src/spec.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants