-
Notifications
You must be signed in to change notification settings - Fork 167
fix(ios): zip interoperability for server-side unzippers (#367) #371
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
Merged
plrthink
merged 3 commits into
cursor/cancel-error-codes-b7ed
from
cursor/ios-zip-compatibility-b7ed
Aug 15, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #!/usr/bin/env node | ||
| /** | ||
| * Lightweight ZIP interoperability check for archives produced by this library. | ||
| * | ||
| * Validates: | ||
| * - local file header signature 0x04034b50 | ||
| * - end-of-central-directory signature 0x06054b50 | ||
| * | ||
| * Usage: node scripts/validate-zip-header.js <file.zip> [more.zip ...] | ||
| */ | ||
| const fs = require('fs'); | ||
|
|
||
| const LOCAL_FILE_HEADER = 0x04034b50; | ||
| const END_OF_CENTRAL_DIR = 0x06054b50; | ||
|
|
||
| function readUInt32LE(buf, offset) { | ||
| return buf.readUInt32LE(offset); | ||
| } | ||
|
|
||
| function validateZip(filePath) { | ||
| const buf = fs.readFileSync(filePath); | ||
| if (buf.length < 22) { | ||
| throw new Error(`${filePath}: file too small to be a zip (${buf.length} bytes)`); | ||
| } | ||
|
|
||
| const localSig = readUInt32LE(buf, 0); | ||
| if (localSig !== LOCAL_FILE_HEADER) { | ||
| throw new Error( | ||
| `${filePath}: bad local header signature 0x${localSig.toString(16)} (expected 0x04034b50)` | ||
| ); | ||
| } | ||
|
|
||
| // EOCD is at the end; comment can make it earlier. Scan last 64KiB. | ||
| const scanFrom = Math.max(0, buf.length - 65557); | ||
| let eocd = -1; | ||
| for (let i = buf.length - 22; i >= scanFrom; i--) { | ||
| if (readUInt32LE(buf, i) === END_OF_CENTRAL_DIR) { | ||
| eocd = i; | ||
| break; | ||
| } | ||
| } | ||
| if (eocd < 0) { | ||
| throw new Error(`${filePath}: end-of-central-directory signature not found`); | ||
| } | ||
|
|
||
| console.log(`OK ${filePath} (local=0x04034b50, eocd@${eocd})`); | ||
| } | ||
|
|
||
| const files = process.argv.slice(2); | ||
| if (files.length === 0) { | ||
| console.error('Usage: node scripts/validate-zip-header.js <file.zip>...'); | ||
| process.exit(2); | ||
| } | ||
|
|
||
| let failed = false; | ||
| for (const file of files) { | ||
| try { | ||
| validateZip(file); | ||
| } catch (err) { | ||
| console.error(String(err.message || err)); | ||
| failed = true; | ||
| } | ||
| } | ||
| process.exit(failed ? 1 : 0); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.