Commit Graph

1485 Commits

Author SHA1 Message Date
Robert Haines 7f7c4ca194 Update README after the move to Ruby >= 2.5. 2022-01-11 22:26:50 +00:00
Robert Haines cf258bbb71 Move to ruby 2.5 as the earliest supported version.
2.4 is nearly two years beyond EOL now.

Closes #484.
2022-01-11 22:26:09 +00:00
Robert Haines 90728d7109 Add `-v` switch to ruby for all tests. 2022-01-11 13:24:35 +00:00
Robert Haines 20952ef38f Update version numbers in the README test matrix. 2022-01-11 13:19:31 +00:00
Robert Haines 3fbc5e62f9 Add the YJIT tests to the README matrix. 2022-01-11 13:15:48 +00:00
Robert Haines 9bed9d0539 Expand the YJIT tests into a mini matrix.
Test 3.1 and head on Ubuntu and MacOS.
2022-01-11 13:02:00 +00:00
Robert Haines 099d379c82 Add an extra test for YJIT in ruby 3.1.
I tried adding this to the matrix, but I couldn't work out how to do
this *and* keep a vanilla 3.1 test in the mix as well. It seems you
can't add different `env`s with `include`, but maybe I missed something.
2022-01-10 18:16:00 +00:00
Robert Haines e04c9cdbd8 Update compatibility matrix in the README. 2022-01-02 13:57:09 +00:00
Robert Haines 8f743d7f68 Make ruby versions list in the CI consistent.
Ruby version `3.0` must be quoted otherwise it's interpreted as `3`.
Might as well make the rest in the list consistent.
2022-01-02 13:09:06 +00:00
Taichi Ishitani 1c33f2dd90 add Ruby 3.1 to CI 2022-01-02 13:06:07 +00:00
Robert Haines 14b63f68db Ensure `File.open_buffer` doesn't rewrite unchanged data. 2021-11-30 22:22:37 +00:00
Robert Haines f5e19db273 Add a 100,000 file zip to test `count_entries`. 2021-11-20 20:02:47 +00:00
Robert Haines 22e47641e6 Add `File::count_entries`.
This method provides a short cut to finding out how many entries are in
an archive by reading this number directly from the central directory,
and not iterating through the entire set of entries.
2021-11-20 10:53:00 +00:00
Robert Haines 3db1eff1e3 Add `CentralDirectory#count_entries`.
This method gets the number of entries from a zip archive without
loading all of the individual entries.
2021-11-20 10:50:55 +00:00
Robert Haines 6a516fb0b1 Factor out reading EOCD records.
This allows for reading the EOCD records without then automatically
reading all of the entry data as well, so that we can do other things
faster, like provide the number of entries in an archive.
2021-11-20 10:36:32 +00:00
Robert Haines 765cb316f1 Fix reading unknown extra fields.
When loading extra fields from both the central directory and local headers,
unknown fields were not merged correctly. They were being appended, which
means that we end up with the two versions stuck together - in some
cases duplicating the field completely.

This broke all kinds of things (like calculating the size of a local
header) in subtle ways.

This commit fixes this by implementing a new `Unknown` extra field type,
and making sure that when reading local and central extra fields they
are stored and preserved correctly. We cannot assume the unknown fields
use the same data in the local and central headers.

Fixes #505.
2021-11-19 19:53:38 +00:00
Robert Haines f7cd692e15 Fix reading zip files with max length file comment.
If a zip file has a comment that is 65,535 characters long - which is a
valid length and the maximum allowable length - the initial read of the
archive fails to find the End of Central Directory Record and therefore
cannot read the rest of the file.

This commit fixes this by making sure that we look far enough back into
the file from the end to find the EoCDR. Test added to catch
regressions.

Fixes #508.
2021-11-19 19:35:36 +00:00
Robert Haines bc6523ec43 Unpick changes from v2.3.1. 2021-07-05 22:22:01 +01:00
Robert Haines c3b1e5d693 Pick changes from v2.3.1. 2021-07-03 13:45:22 +01:00
Robert Haines 54b7762c8f Don't silently alter zip files opened with `Zip::sort_entries`.
Fixes #329.
2021-06-30 23:18:59 +01:00
Yo Yehudi 322955c6b4 add research notice
so that contributors will be aware metrics are being gathered on this repo over the  next year.  If there's a better place to put this please let me know. :)
2021-06-28 13:18:45 +01:00
Robert Haines 66527ae10d Fix minor typo in `GPFBit3Error` message in `InputStream`. 2021-06-27 21:55:15 +01:00
Robert Haines 19e5f4a8ce Detect and raise GPFBit3Error in `InputStream.get_next_entry`.
We were previously trying to work out where the next entry would be,
even with GP bit 3 set, but the logic was flaky and cannot really be
correct given the data available. It's not expected behaviour, so raise
the error instead.

This means that we get rid of the incorrect `Entry.data_descriptor_size`
which was doing more harm than good.
2021-06-27 21:43:03 +01:00
Robert Haines 8071290ce6 Update and tidy up encryption tests. 2021-06-27 15:56:39 +01:00
Robert Haines 50dddca0be Update encrypted fixtures to remove data descriptors. 2021-06-27 15:54:08 +01:00
Robert Haines bb237aaa08 Update authors in gemspec to reflect current maintainers. 2021-06-27 11:47:31 +01:00
Robert Haines f005ca2864 Update the list of files packaged in the gemspec. 2021-06-27 11:30:09 +01:00
Robert Haines 81d95ad0a3 Minor gemspec formatting changes for space/readability. 2021-06-27 11:29:55 +01:00
Robert Haines 1fb74bd82f Don't mess with the library path in the gemspec. 2021-06-27 11:04:53 +01:00
Robert Haines 9fc12bf97b Add notes to the README and Changelog about the new API. 2021-06-27 10:20:11 +01:00
Robert Haines aa646ef827 Use named params for `InputStream`. 2021-06-27 10:20:11 +01:00
Robert Haines f75eb61578 Use named parameters for `File#get_output_stream`. 2021-06-27 10:20:11 +01:00
Robert Haines debc9fda91 Use named parameters for `File::split`. 2021-06-27 10:20:11 +01:00
Robert Haines f033ae760d Use named parameters for `File::new`.
This is a breaking change, but now is the time to do this as we've
already done the same for `Entry::new`.
2021-06-27 10:20:11 +01:00
Robert Haines e1e1cab39c Fix some non-writable `StringIO`s. 2021-06-27 10:20:11 +01:00
Robert Haines 659db85bff `open` and `write_buffer` in `OutputStream` use named params. 2021-06-27 10:20:11 +01:00
Robert Haines 7ae90be63e Fix Style/OptionalBooleanParameter in `OutputStream`. 2021-06-27 10:20:11 +01:00
Robert Haines e7f0aba5ff Fix Style/OptionalBooleanParameter cop in `Entry`.
Just an internal API so safe, and makes things a lot neater.
2021-06-27 10:20:11 +01:00
Yuya.Nishida f76cef90f7 Remove newer duplicated line 2021-06-26 22:53:37 +01:00
Robert Haines 8699e356d4 Improve documentation for `File.glob`.
Closes #338.
2021-06-26 20:04:17 +01:00
Robert Haines a301d68eeb Raise an error if entry names exceed 65,535 characters.
Fixes #247.
2021-06-26 19:21:07 +01:00
Robert Haines 49e313629e Remove the `ZipXError` v1 legacy classes. 2021-06-26 17:39:25 +01:00
Robert Haines e000552deb Raise an error on reading a split archive with `InputStream`.
Fixes #349.
2021-06-26 12:39:08 +01:00
Robert Haines 193507b15a Adjust Layout/LineLength cop to 100 characters.
We'll get the line length down in stages...
2021-06-25 22:31:34 +01:00
Robert Haines de6ec15610 Update Changelog. 2021-06-25 17:54:30 +01:00
Robert Haines 84b3e8c644 Ensure `InputStream` raises `GPFBit3Error` for OSX Archive files.
Fixes #493.
2021-06-25 17:53:18 +01:00
Robert Haines 78565db40c Simplify `InputStream.open_entry`.
Also ensure `@complete_entry` is initialized!
2021-06-25 17:53:18 +01:00
Robert Haines c29297c0b8 Add a test to ensure `InputStream` raises `GPFBit3Error`. 2021-06-25 17:53:18 +01:00
Robert Haines ac053bd787 Improve documentation and error messages for `InputStream`.
Closes #196.
2021-06-25 16:58:01 +01:00
Robert Haines 1183607ea1 Flush buffered `OutputStream` on close.
Fixes #265.
2021-06-23 22:24:44 +01:00