Commit Graph

1460 Commits

Author SHA1 Message Date
Robert Haines 1c06454985 Update minimum ruby version to 3.0.
All rubies before 3.0 are EOL and this is a major version bump, so it's
the right time to do this.
2024-03-01 22:14:48 +00:00
Kyle Huston b1ee5cf272 Note write_zip64_support default is false before 3.0
Improve accuracy of readme to note that write_zip64_support
is enabled by default in versions 3.0 and later.
2024-02-24 18:33:52 +00:00
Robert Haines fd0cf5443e Update ZipCrypto instructions for 2.x versions.
Suggested by @KamilDzierbicki in #568.
2024-02-24 17:52:33 +00:00
Robert Haines e3c173b0fc Update the compatibility matrix in the README. 2024-02-24 17:36:52 +00:00
m-nakamura145 5e9a9cbf18 Add Ruby 3.3 to CI matrix 2024-02-24 17:15:35 +00:00
MSP-Greg f811b2d00e Update README.md 2023-08-12 09:51:01 +01:00
MSP-Greg bb09f90ef9 Action - add 2 Windows head builds 2023-08-12 09:51:01 +01:00
Robert Haines 8cec9491b2 README: add link to wiki for version 3 details. 2023-04-16 16:13:30 +01:00
OZAWA Sakuro a2fc20db8f Zip::InputStream#read returns '' with 0 2023-04-14 11:25:22 +01:00
OZAWA Sakuro a4f9ec6423 Add compatibility test for Zip::InputStream#read(0) 2023-04-14 11:25:22 +01:00
Peter Boling 3ce504fcfb Fix typo know -> known 2023-04-14 11:25:22 +01:00
Robert Haines efa0035634 Turn on yjit for Ruby 3.2 in CI. 2023-04-14 11:25:22 +01:00
Peter Goldstein c0a3c95eee Add Ruby 3.2 to the CI matrix. 2023-04-14 11:25:22 +01:00
Robert Haines e672c46895 Use an updated rubygems in the tests CI.
This is needed for Ruby 2.5, which we need to support a bit longer.
2023-04-14 11:25:22 +01:00
Robert Haines f4a1a09962 Update the linter CI to use Ruby 2.6. 2023-04-14 11:25:22 +01:00
Robert Haines f5ea5a8708 Update Actions to use checkout@v3. 2023-04-14 11:25:22 +01:00
Robert Haines 2ffbfebb88 Document or hide classes from the docs. 2023-04-14 11:25:22 +01:00
Robert Haines 0aa10bf7d5 Document or hide modules from the docs. 2023-04-14 11:25:22 +01:00
Robert Haines 016e1000ba Suppress Rubocop extension notice. 2023-04-14 11:25:22 +01:00
Robert Haines edeab0713c Add RDoc and tasks to the Rakefile. 2023-04-14 11:25:22 +01:00
Robert Haines ccc3d4ff1a Set version to be 3.0.0.alpha. 2023-04-14 11:25:22 +01:00
Robert Haines 84087e5774 Ensure that entries can be extracted safely without path traversal.
This commit adds a parameter to the `File#extract` and `Entry#extract` methods
so that a base destination directory can be specified for extracting archives
in bulk to somewhere in the filesystem that isn't the current working
directory. This directory is `.` by default. It is combined with the entry
path - which shouldn't but could have relative directories (e.g. `..`) in it -
and tested for safety before extracting.

Resolves #540.
2023-04-14 11:15:24 +01:00
Robert Haines 58f053afb0 Only use the Zip64 CDIR end locator if needed.
Previously the central directory Zip64 data was written even if it wasn't
strictly needed. The standard allows for entries to include Zip64 data
(say, if they are streamed and their size is unknown when writing the file
data) without needing any Zip64 data in the central directory. So now we
only write central directory Zip64 data if there are over 65535 files or
the file data is huge.
2023-01-03 20:19:40 +00:00
Robert Haines f460da3afb Prevent unnecessary Zip64 data being stored.
With Zip64 write support enabled by default, it's important that we
only store the extra data when we need to. This commit ensures that
the Zip64 extra data is included for an entry if its size is over
4GB, or if we don't know how big it will be at the point of writing
the local header data.

This commit also removes the need for the Zip64Placeholder extra
data field. Now we just use the Zip64 field itself and ensure it's
filled in correctly.
2023-01-03 20:19:40 +00:00
Stan Hu d6eb73566c Enable Zip64 by default
Previously if RubyZip attempted to create an archive with more than
64K entries, the central directory would truncate the count. `unzip`
and `zipinfo` would fail with an error message such as:

```
error:  expected central file header signature not found (file #93272).
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)
```

This generated a lot of confusion and a production issue since many
tools fail to decode a RubyZip-created archive if Zip64 is not enabled
for a large number of files. Since Zip64 support is now the norm,
enable this by default.
2023-01-03 20:19:40 +00:00
Robert Haines 750d372380 Rename DestinationFileExistsError -> DestinationExistsError.
And define the error message within the class.
2022-08-16 11:13:30 +01:00
Robert Haines e3f0aecf93 Define the EntryNameError message within the error class. 2022-08-16 10:52:18 +01:00
Robert Haines 07eca2bae8 Define the EntrySizeError message within the error class. 2022-08-15 22:02:33 +01:00
Robert Haines 7097492dc8 Define the EntryExistsError message within the error class. 2022-08-14 22:23:51 +01:00
Robert Haines 04cc10a80f Remove the InternalError class (never used). 2022-08-14 22:23:51 +01:00
Robert Haines 51231673a4 Define the DecompressionError message within the error class. 2022-08-14 22:23:51 +01:00
Robert Haines 19fe79e31e Define the SplitArchiveError message within the error class. 2022-08-14 22:23:51 +01:00
Robert Haines 03a9ee6b8a Rename `GPFBit3Error` to `StreamingError`.
`GPFBit3Error` doesn't really mean anything to the general user, and
it's not descriptive of the issue at hand. This error is raised when a
zip file cannot be streamed via `InputStream`, so `StreamingError` makes
more sense.

Also standardize the error message while we're about it.
2022-08-14 22:23:51 +01:00
Robert Haines 2e4dd9e0aa Improve the message for CompressionMethodError.
Convert the compression method number into a meaningful text
representation, e.g., "BZIP2" instead of "12".
2022-08-14 22:23:51 +01:00
Robert Haines 08391da4d5 Ensure that `Entry.ftype` is correct via `InputStream`.
When reading an archive with `InputStream`, `Entry.ftype` was returning
`:file` for all entries, even if they were a directory. This is due to
various side-effects in many methods in `Entry`. This commit fixes the
behaviour, but not the side-effects.

Fixes #533.
2022-08-13 22:09:55 +01:00
Brian Williams 6f1ad8b37d Fix unraised error on encrypted archives 2022-08-09 22:11:42 +01:00
Robert Haines 708b7f5393 Add a couple more checks in the tests for double `commit`s.
Just ensure that a `commit` really does stick with both new and edited
zip files.
2022-06-25 08:53:35 +01:00
Robert Haines 14ff11ba05 Re-initialize CDir after a `commit`.
Using the factored-out code preserves options set in `File`.

Fixes #529.
2022-06-25 08:51:32 +01:00
Robert Haines c243b4429a Factor out the code in `File` to init the CDir.
This allows us to reuse it without overwriting any options passed to `File`.
2022-06-25 08:48:23 +01:00
Robert Haines 6486047d5f Use the new `Entry` time methods in `Filesystem::File`. 2022-06-20 17:18:20 +01:00
Robert Haines 466383ff1a Add other `Entry` time methods and test them all. 2022-06-20 17:18:20 +01:00
Robert Haines fff1f8ea8a Add `Entry#mtime=` as an alias of `Entry#time=`. 2022-06-20 17:18:20 +01:00
Robert Haines 62ed397b1a Generalize `Entry#time=`.
So we can use it for `atime=`, `ctime=` and `utime=` as well.
2022-06-20 17:18:20 +01:00
Robert Haines d6482bd567 Generalize `Entry#time`.
So we can use it for `atime`, `ctime` and `utime` as well.
2022-06-20 17:18:20 +01:00
Robert Haines ae0262df2e Add `Entry#zip64?` as a better way detect Zip64 entries. 2022-06-20 17:18:20 +01:00
Robert Haines 307fc6c6e9 Mark other mutating methods in `Entry` as dirty.
Also, remove `Entry#extra=` as it makes no sense (and wasn't even being
tested).

And remove slightly odd test that was assuming an archive would not be
changed if its utime was changed - even if it was being changed back
immediately. This test was merely confirming that we weren't catching
timestamp changes correctly.
2022-06-20 17:18:20 +01:00
Robert Haines 33dce510a6 Remove `Entry#dirty=` as 'dirtyness' is now monitored internally.
Had to round out some of the accessors that mark an `Entry` as dirty.
2022-06-20 17:18:20 +01:00
Robert Haines 5cd1ef2910 Use new dirty statuses to detect zip file changes.
This also means that we no longer need to keep a copy of the original
set of `Entry`s or the central directory comment to test for changes.

For situations where a zip file has a lot of entries (e.g. #506) this
means we save a lot of memory, and a lot of time constructing the zip
file in memory.
2022-06-20 17:18:20 +01:00
Robert Haines 08641db9f8 Make `CentralDirectory` dirtyable. 2022-06-20 17:18:20 +01:00
Robert Haines 7b340d62a6 Abstract marking as dirty into `Dirtyable` for reuse. 2022-06-20 17:18:20 +01:00