Commit Graph

588 Commits

Author SHA1 Message Date
David Ryskalczyk a420323c84 require pathname where it is used 2019-02-10 11:51:29 -05:00
Mihyaeru afb1b79efd remove some strange commas 2018-12-04 00:14:32 +09:00
John Lees-Miller fd81bd523c Bump version to 1.2.2 2018-08-27 09:07:21 +01:00
John Lees-Miller cf35774ed6 Bump version to 1.3.0 2018-08-27 09:02:11 +01:00
John Lees-Miller ffb374c6b1 Bump version to 2.0.0 2018-08-27 08:37:53 +01:00
John Lees-Miller 8a1de58286 Expand from root rather than current working directory 2018-08-26 19:55:26 +01:00
John Lees-Miller 3dd165b494 Disable symlinks and check for path traversal 2018-08-26 14:21:38 +01:00
Bart de Water 8e78311d67 Fix CVE-2018-1000544 symlink path traversal
Not sure if the exception is the right way to go
2018-08-23 18:14:48 -04:00
Bart de Water 6e0d23178a Fix CVE-2018-1000544 absolute path traversal
Small refactor along the way to centralize destination handling when no explicit path is given and a potential malicious one from the zipfile is used
2018-08-23 18:14:48 -04:00
Robert Haines aa6284db7a When globbing in ZipFSDir, take CWD into account. 2018-04-30 20:06:21 +01:00
Robert Haines 1673da744d Pass glob through from ZipFileNameMapper.
Just pass the basic glob straight through to the underlying Zip::File
implementation.
2018-04-30 19:59:02 +01:00
Robert Haines 84c208982f Switch newly created StringIOs to binmode.
StringIO objects created within File.open_buffer were not being switched into
binmode, but those passed in were. Fix this inconsistency and add a test.
2018-04-04 16:02:19 +01:00
Robert Haines 15ccc25da1 Fix File.open_buffer when no changes are made.
Things are now more carefully set up, and if a buffer is passed in which
represents a file that already exists then this is taken into account. All
initialization is now done in File.new, rather than being split between there
and File.open_buffer.

This has also needed a bit of a re-write of Zip::File.initialize. I've tried to
bring some logic to it as a result, and have added comments to explain what is
now happening.
2018-04-04 15:54:12 +01:00
Robert Haines 03633933eb No need to require stringio in Zip::File.open_buffer.
It's already required in zip.rb.
2018-04-04 14:31:34 +01:00
Robert Haines cfa9441914 Handle passing an IO to Zip::File.new better.
This now actually extracts the path from the IO if one is passed in.
2018-04-03 23:48:54 +01:00
Robert Haines 7cd263e6a0 Clean up use of file_name in Zip::File::initialize. 2018-04-03 23:45:04 +01:00
Andrew Meyer c787d94852 Handle stored files with general purpose bit 3 set
Signed-off-by: Sam Coward <scoward@pivotal.io>
2018-04-03 16:07:18 -04:00
Oleksandr Simonov 05af1231f4
Merge pull request #353 from pnomolos/pnomolos/fix_stringio
Added fix for calling 'close' on a StringIO-backed zip file, and specs
2018-03-30 16:58:27 +03:00
Phil ffd0b671b8 Fix regression caused by Rubocop cleanup
InputStream:

```
if @current_entry && @current_entry.gp_flags & 8 == 8 && @current_entry.crc == 0 \
  && @current_entry.compressed_size == 0 \
  && @current_entry.empty? && !@internal
```

`Zip::Entry#empty?` doesn't exist, but an automatic Rubocop check thought it should be converted from `size == 0`.

Unfortunately, this is tricky to write a test for as it only fails under some very specific conditions.
2018-02-23 13:22:57 -08:00
Phil 792266dbf3 Added fix for calling 'close' on a StringIO-backed zip file, and specs 2018-02-21 11:48:56 -08:00
Oleksandr Simonov 57c3772d94
Merge pull request #325 from aeroastro/feature/tempfile-directory
Save temporary files to a temporary directory
2017-11-08 20:38:22 +02:00
Alexey Sorokin deb6616c5f Merge branch 'master' into force-entry-names-encoding-option 2017-10-18 19:24:58 +03:00
Alexey Sorokin a9f020c0a0 add option to force entry names encoding
if you need to work with existing zip files which contain names with
non-ascii characters then you can specify this option.
Without this option find_entry will not work properly
2017-10-18 18:20:56 +03:00
Takumasa Ochi cf91112b57 Apply automatic correction by rubocop 2017-06-29 11:57:12 +09:00
Takumasa Ochi 258ef02914 Save temporary files to a temporary directory 2017-06-27 09:17:55 +09:00
Alexander Simonov 98f4f2ed9b
Version bump 2017-02-08 13:50:16 +02:00
Alexander Simonov ce4208fdec
Fix #315 and resolve relative path vulnerability 2017-02-08 13:43:14 +02:00
Alexander Simonov df8dfbcff3 Merge pull request #314 from mwlang/bugfix/open_buffer_without_block
allows open_buffer to work without a given block
2017-02-08 13:16:06 +02:00
mwlang 14b8fed18c allows open_buffer to work without a given block 2017-01-16 13:24:22 -06:00
Koichi ITO 960414aff0 Fix warnings: `constant ::Fixnum is deprecated` in Ruby 2.4 2017-01-08 16:41:23 +09:00
dogatana a4e3b55bb2 remove tr to support cp932 encoding 2016-12-07 22:35:33 +09:00
Alexander Simonov a0cf673186 Merge pull request #300 from hainesr/fix-create-perms
Fix permissions on new zip files (#294)
2016-11-09 22:19:04 +02:00
Alexander Simonov 82fa57cc83 Merge pull request #303 from deivid-rodriguez/extended_globbing
Extended globbing
2016-11-09 22:17:17 +02:00
knut2 579e78f1ef Update entry.rb
Add accessor to @internal_file_attributes
See http://stackoverflow.com/questions/39800771/hot-to-set-binary-flag-in-zip-file-with-rubyzip
2016-10-10 23:04:36 +02:00
David Rodríguez 9c475f5160 Add extended globbing support 2016-10-08 19:32:53 -03:00
Robert Haines c00d767533 Fix rubocop offence caused by temp files changes. 2016-09-05 17:34:12 +01:00
Robert Haines fc23f68f77 Refactor the create logic in Zip::File.
Make the internal @create varible more consistent and actually match the
documentation.

Zip::File::CREATE is now true, rather than 1.

A new test is added to check if passing 1 in still works to ensure backwards
compatibility.
2016-09-05 15:16:57 +01:00
Robert Haines 63ed0d970b Refactor the code which manages temp files.
Combine the creation of the temporary filename with the writing to it.
2016-09-05 15:07:18 +01:00
Robert Haines 7b14d11c00 Stop using 0600 perms for temporary files.
This fixes #294 in what I hope is a more sensible way than trying to mess with
umasks, etc, directly.

Temporary files were being created with 0600 permissions and then being set to
different permissions, based on umask, etc, afterwards. I don't know what the
rationale for this was, but there were errors in the umask calculations when
moving from the temporary file to the intended end result.
2016-09-01 12:10:56 +01:00
Alexander Simonov 3ec40d875d
Version bump 2016-02-19 11:14:57 +02:00
Alexander Simonov 560bf5d432 Merge pull request #259 from mnaberez/remove-tempfile
Fix accidental unlink (#185) without using ObjectSpace (#252)
2016-01-05 00:37:53 +02:00
Alexander Simonov 972749c518 Merge pull request #263 from ShockwaveNN/feature/fix-warn-date-tests
Add correct test for `Zip.warn_invalid_date` attribute
2016-01-05 00:37:17 +02:00
Oleksandr Avoiants 73bfa5955c Fix TypeError: can't dup NilClass from EntrySet#dup 2015-12-19 11:26:20 +02:00
Pavel Lobashov 73a35d4515 User `warn` method instead `STDERR.puts` to correctly check error in tests
See http://stackoverflow.com/questions/34351144/minitest-assert-output-incorrect-check-for-stderr
about this
2015-12-18 16:40:24 +03:00
Mike Naberezny 6e1dea4f66 Fix accidental unlink (#185) without using ObjectSpace (#252) 2015-11-22 14:40:59 -08:00
Alexander Simonov 8447f0e230
Fix #252 2015-11-21 12:07:30 +02:00
Felix Bünemann 7a4b8bb048 Fix high memory usage due to Deflater buffering
When support for ZipCrypto was added, an internal StringIO buffer was
added to Deflater, in order to fix a decryption bug. While this worked,
it caused unlimited memory growth when compressing large files. The
proper fix is to writer the encryption header in init_next_entry instead
of finalize_current_entry, so the headers are written before any
encrypted data. Because of this fix we can remove the buffering in
Deflater, which keeps memory usage low and allows to stream compressed
data while it is written.

This should fix issue #233.
2015-10-17 17:06:41 +02:00
Victor Costan 77acc03ddb Fix exception due to calling empty? on nil. 2015-09-30 03:57:21 -04:00
Seth Kingsley 05a9ba3f20 Use duck typing to detect IO-like objects. 2015-09-03 06:16:32 -07:00
Claire Pitman a1f75a3ab9 Added error for empty (zero bit) zip file. Added tests for empty and non existant zips 2015-07-27 23:20:59 -07:00
Victor Costan 37a5baad96 Accept StringIO in Zip.open_buffer. 2015-07-02 14:17:17 -04:00
Robert Haines 9acc50f004 Do something more expected with new file permissions.
Instead of inheriting the permissions from the tmp directory, new files should
have permissions that reflect the defaults on the system taking umask into
account.

It seems that (unix) permissions of 666 - umask are as close to a standard as
anything [1] and that 'touch' uses this. On Windows it seems sensible to just
use 644 directly [2].

[1] http://unix.stackexchange.com/a/102080
[2] http://ruby-doc.org/core-1.9.3/File.html
2015-06-24 18:25:22 +01:00
Pavel Lobashov 1e99ff69b9 Revert "fix rubocop cop Style/ClassCheck". It cause regression in tests
This reverts commit 8c13dfc265.
2015-06-08 10:45:23 +03:00
Pavel Lobashov 8c13dfc265 fix rubocop cop Style/ClassCheck 2015-06-08 10:36:41 +03:00
Pavel Lobashov 4c81b1151a fix rubocop cop Style/NilComparison 2015-06-08 10:30:12 +03:00
Pavel Lobashov 13658b0586 fix rubocop cop Style/NonNilCheck 2015-06-08 10:29:08 +03:00
Pavel Lobashov f7eec2dd76 fix rubocop cop Style/SpaceAroundOperators 2015-06-08 10:26:13 +03:00
Pavel Lobashov c0177a455b Merge branch 'master' into rubocop_fixes
Conflicts:
	README.md
	samples/example_recursive.rb
2015-06-08 10:14:25 +03:00
Alexander Simonov d289780072 Fix #234. Add special variable what is a flag about internal usege 2015-06-07 17:29:54 +03:00
Vít Ondruch 32016ab1bf Remove executable bit. 2015-03-31 13:15:46 +02:00
Pavel Lobashov 2007be0ab6 fix rubocop Lint/UselessAccessModifier cop 2015-03-24 19:47:49 +03:00
Pavel Lobashov fd864bd7ab fix rubocop Style/CaseEquality cop 2015-03-24 19:44:47 +03:00
Pavel Lobashov 96f3997f07 fix rubocop Style/GuardClause cop 2015-03-24 19:33:15 +03:00
Pavel Lobashov ce7e01a206 fix rubocop Style/CommentIndentation cop 2015-03-24 19:31:28 +03:00
Pavel Lobashov 784e70be2a fix rubocop Style/EmptyElse cop 2015-03-24 19:29:07 +03:00
Pavel Lobashov 112a77de7c fix some Style/FormatString cop 2015-03-24 19:20:39 +03:00
Pavel Lobashov b920a1eb49 fix rubocop Style/GuardClause cop 2015-03-24 19:16:03 +03:00
Pavel Lobashov b9aefaffb5 fix rubocop Style/IfUnlessModifier cop 2015-03-24 19:09:22 +03:00
Pavel Lobashov 2c8f6f8cbd fix correct initialization for ExtraField 2015-03-24 19:04:28 +03:00
Pavel Lobashov b1bfb1a216 fix some rubocop Style/ModuleFunction cop 2015-03-23 19:36:47 +03:00
Pavel Lobashov 1ba81ff46f fix rubocop Style/NumericLiterals cop 2015-03-23 19:23:04 +03:00
Pavel Lobashov 31fb9d729b fix rubocop Style/PredicateName cop 2015-03-23 19:18:51 +03:00
Pavel Lobashov f291e1f616 fix rubocop Style/NegatedIf cop 2015-03-23 19:11:32 +03:00
Pavel Lobashov 6a7a22fece fix rubocop Style/MultilineOperationIndentation cop 2015-03-23 19:10:39 +03:00
Pavel Lobashov 47b72f5cab fix rubocop Style/LeadingCommentSpace cop 2015-03-23 19:06:01 +03:00
Pavel Lobashov d5f79822c1 fix rubocop Style/LineEndConcatenation cop 2015-03-23 19:03:28 +03:00
Pavel Lobashov edf3126599 EntrySet.dub fix for code-style 2015-03-23 18:57:56 +03:00
Pavel.Lobashov 8d6f23ba9a fix rubocop Style/SpaceAroundOperators cop 2015-03-22 20:03:50 +03:00
Pavel.Lobashov 5ea5710b18 fix rubocop Style/SpaceBeforeBlockBraces cop 2015-03-22 19:59:33 +03:00
Pavel.Lobashov d92d8d652a fix rubocop Style/SpaceInsideParens cop 2015-03-22 19:56:37 +03:00
Pavel.Lobashov b13fafb7e8 fix rubocop Style/StringLiterals cop 2015-03-22 19:54:44 +03:00
Pavel.Lobashov b311998e25 fix rubocop Style/SpaceInsideBlockBraces cop 2015-03-22 19:49:07 +03:00
Pavel.Lobashov cb143f0cff fix rubocop Style/SpaceAroundEqualsInParameterDefault cop 2015-03-22 19:45:26 +03:00
Pavel.Lobashov 77ef05cf84 fix rubocop Style/SpaceAfterNot cop 2015-03-22 19:44:44 +03:00
Pavel.Lobashov 73e5f70bdf fix rubocop Style/SpaceAfterMethodName cop 2015-03-22 19:43:44 +03:00
Pavel.Lobashov d2b4a528de fix rubocop Style/SpaceAfterComma cop 2015-03-22 19:41:47 +03:00
Pavel.Lobashov 707bd44e66 fix rubocop Style/SingleLineMethods cop 2015-03-22 19:37:59 +03:00
Pavel.Lobashov 735a0553a3 fix rubocop Style/RedundantBegin cop 2015-03-22 19:33:44 +03:00
Pavel.Lobashov 105c2c71b2 fix rubocop Style/RedundantException cop 2015-03-22 19:32:47 +03:00
Pavel.Lobashov abf9cbec23 fix rubocop Style/RedundantSelf cop 2015-03-22 19:30:24 +03:00
Pavel.Lobashov 225a4f70ce fix rubocop Style/RedundantReturn cop 2015-03-22 19:27:29 +03:00
Pavel.Lobashov 06e5a9352d fix rubocop Style/ParenthesesAroundCondition cop 2015-03-22 19:25:35 +03:00
Pavel Lobashov b730387cf2 redone fixes by rubocop Style/Alias to be in style of https://github.com/bbatsov/ruby-style-guide#alias-method-lexically 2015-03-21 13:14:21 +03:00
Pavel Lobashov da863e4b55 Merge branch 'master' into rubocop_fixes
Conflicts:
	lib/zip/entry.rb
2015-03-21 11:37:28 +03:00
Pavel Lobashov b93ef1266f fix rubocop Style/StringLiterals cop 2015-03-21 11:27:44 +03:00
Pavel Lobashov f67cf18e45 fix rubocop Style/EmptyLinesAroundModuleBody cop 2015-03-21 11:22:47 +03:00
Pavel Lobashov b9a757e045 fix rubocop Style/EmptyLinesAroundClassBody cop 2015-03-21 11:21:26 +03:00
Pavel Lobashov eba5fa1983 fix rubocop Style/EmptyLinesAroundAccessModifier cop 2015-03-21 11:19:43 +03:00
Pavel Lobashov d0c8e8df60 fix rubocop Style/EmptyLines cop 2015-03-21 11:19:14 +03:00
Pavel Lobashov 6c46c21abb fix rubocop Style/ColonMethodCall cop 2015-03-21 11:16:06 +03:00
Pavel Lobashov a0da550c22 fix rubocop Style/CaseIndentation cop 2015-03-21 11:12:01 +03:00
Pavel Lobashov d2d8590ef8 fix rubocop Style/Blocks cop 2015-03-21 11:10:37 +03:00
Pavel Lobashov 0c6a10e631 fix rubocop Style/AndOr cop 2015-03-21 10:48:05 +03:00
Pavel Lobashov a2afbafacf fix rubocop Style/AndOr cop 2015-03-21 10:45:46 +03:00
Pavel Lobashov 98e6b5d057 fix rubocop Style/AlignParameters cop 2015-03-21 10:44:56 +03:00
Pavel.Lobashov bb08213cb7 fix rubocop Style/Alias cop 2015-03-20 23:17:05 +03:00
Pavel.Lobashov 4ee6d6be39 fix rubocop Lint/UnusedMethodArgument cop 2015-03-20 23:09:41 +03:00
Pavel.Lobashov d3e911f04d fix rubocop Lint/UnusedBlockArgument cop 2015-03-20 23:07:59 +03:00
Pavel.Lobashov 67838e13ac fix rubocop Lint/EndAlignment cop 2015-03-20 23:00:20 +03:00
Pavel.Lobashov 6d19df491a fix rubocop Lint/AssignmentInCondition cop 2015-03-20 22:57:38 +03:00
Pavel.Lobashov d928aeebe5 make parse_zip64_extra check for empty @extra['Zip64'] easier to read 2015-03-20 22:54:28 +03:00
Pavel.Lobashov c45a639c54 fix rubocop Style/TrailingBlankLines cop 2015-03-20 22:45:50 +03:00
Pavel.Lobashov 7dcba79bb5 fix rubocop Style/TrailingComma cop 2015-03-20 22:44:21 +03:00
Pavel.Lobashov 6fac8c7e86 fix rubocop Style/TrailingWhitespace cop 2015-03-20 22:43:29 +03:00
Pavel.Lobashov b7cda26ea6 fix rubocop Style/WhileUntilDo сщз 2015-03-20 22:38:09 +03:00
Pavel Lobashov 7a8a8b6fd2 fix rubocop Style/WhileUntilModifier warning 2015-03-20 18:33:43 +03:00
Alexander Simonov 4698e5743e Merge pull request #224 from weshatheleopard/master
Less sloppy implementation of case insensitive matching
2015-03-19 20:10:36 +02:00
Pavel Lobashov 17ac4fdba1 Fix #218
Ouput Invalid Date/time to STDERR
2015-03-19 17:32:33 +03:00
weshatheleopard d81e0f207d Oops, forgot to remove 2015-03-11 09:41:03 -05:00
weshatheleopard f030cdadb8 ...and remove that crazy abomination 2015-03-08 13:40:43 -05:00
weshatheleopard cfc38b30a1 PROPER case insensitivity handling 2015-03-08 13:38:57 -05:00
Alexander Simonov 070411ef5c Merge pull request #222 from rastarobot/find_entry_case_insensitively
Case insensitivity option for #find_entry
2015-03-07 12:22:24 +02:00
Sergey Konotopov b7fa9b124e Fixing Zip#read_local_entry error on JRuby 2015-03-07 12:50:13 +03:00
Sergey Konotopov 61a4435cc3 Case insensitivity option for #find_entry 2015-02-20 01:20:07 +03:00
Alexander Simonov 0cb838f019 Fix #221 2015-02-16 21:51:44 +02:00
Alexander Simonov 0cbae14c76 Version bump 2015-02-03 00:00:09 +02:00
Alexander Simonov 721c1f05ed Merge pull request #201 from mcantor/master
Be smarter about handling buffer file modes
2015-01-17 12:21:32 +02:00
Alexander Simonov 9e7af06a0b Merge pull request #209 from johnnyshields/master
Support for Traditional Encryption (ZipCrypto) + Tests
2015-01-17 12:20:52 +02:00
Alexander Simonov a23b30697a Merge pull request #185 from maneframe/master
prevent tempfile path from being unlinked by garbage collection
2015-01-16 20:43:53 +02:00
Shigeaki Matsumura 85a7bbdf1a add data descriptor for each entries when encrypto 2015-01-08 18:30:32 +09:00
Shigeaki Matsumura bd5a7e4081 fix to file size with encrption 2015-01-07 10:45:01 +09:00
Shigeaki Matsumura 87d1a5a775 added test cases for encryption support 2015-01-06 00:49:16 +09:00
Shigeaki Matsumura fd26052525 fix to encryption bug 2015-01-04 22:49:58 +09:00
Johnny Shields c2ecafe770 Change method interfaces to allow encrypter/decrypter to be passed into stream methods 2015-01-04 04:07:51 +09:00
Johnny Shields 23f2ead7ee - Move encryption related files to /lib/zip/crypto/ dir
- NullEncrypter and NullDecrypter should inherit Encrypter and Decrypter respectively
- Add copyright notice to bottom of added files for consistency
2015-01-04 03:37:43 +09:00
Shigeaki Matsumura c70e5836c7 support traditional encryption 2015-01-01 11:09:17 +09:00
Max Cantor 7c7d786f02 Be smarter about handling buffer file modes. 2014-12-17 16:16:02 -05:00
lobashov 7498e8a9d3 add warn_invalid_date option 2014-12-01 18:39:29 +03:00
Nikolay Petrachkov 5a4d1ba52a Use tr instead of gsub 2014-10-22 16:37:21 +02:00
Henry Yang a7a11e33bd NTFS Extra Field (0x000a) support 2014-09-11 23:04:23 -07:00
James Williams 3b639b6c62 prevent tempfile path from being unlinked by garbage collection 2014-08-29 08:31:56 -06:00
Jason King cf0a5fe386 `Zip.sort_entries` working for zip output 2014-07-24 11:39:37 -07:00
Alexander Simonov d460b81745 Fix #171 2014-07-23 12:59:29 +03:00
Alexander Simonov 2ef328b11b Version bump 2014-07-02 18:17:00 +03:00
Alexander Simonov 2fcdc3a3ea Revert "Return created zip file from Zip::File.open when supplied a block"
This reverts commit e3029d0b10.
2014-07-02 18:15:54 +03:00
Alexander Simonov 2cd56671fc Version bump 2014-07-02 14:11:04 +03:00
Alexander Simonov 62e0a87e49 Merge pull request #166 from layerssss/master
treat empty file as non-exists
2014-07-02 14:07:52 +03:00
Alexander Simonov a989e8c145 Revert "Speed up Deflater sysread speed when number_of_bytes is small and @output_buffer is large"
This reverts commit a800987a52.
2014-07-02 14:05:13 +03:00
Michael Yin fe1d4ade49 treat empty file as non-exists 2014-07-02 12:46:44 +08:00
Alexander Simonov 09011eca6b Merge pull request #141 from zacstewart/master
Add InputStream#ungetc
2014-06-21 17:48:49 +03:00
Tyler Pickett e3029d0b10 Return created zip file from Zip::File.open when supplied a block
This change is to match ruby zip’s behavior to core’s IO.open when
supplied a block.
2014-06-17 10:08:26 -06:00
Alexander Simonov 6b77562d32 Version bump 2014-05-30 20:12:33 +03:00
Mehmet Celik b5c5b6803e Zip::Entry::DEFLATED was forced on every file 2014-04-23 08:42:09 +02:00
mrloop 9eb35ca0c4 Don't send empty string to stream
Unneeded method call removed.
This was causing an issue in rails 4 and zipline
https://github.com/fringd/zipline/pull/10
2014-04-17 13:23:12 +01:00
Alexander Simonov 3ab98483c9 Merge pull request #154 from orien/exception_naming
Alias for legacy error names
2014-04-11 10:03:31 +03:00
Orien Madgwick 9d4292007c alias error names
Ensure we maintain the v1 interface
2014-04-11 08:32:17 +10:00
Alexander Simonov 47ef890de6 Version bump 2014-04-06 18:54:23 +03:00
Orien Madgwick 34f5025d76 default arg for write_buffer
Adding the io parameter to OutputStream::write_buffer breaks backward
compatibility with v1.1.0. Adding a default value reinstates backward
compatibility.
2014-04-06 23:45:19 +10:00
Ian Young 37ed325783 Clean up tempfiles from output stream, fixes #57 2014-04-04 14:32:11 -07:00
Alexander Simonov 527137db5f Version bump 2014-03-18 15:10:31 +02:00
Alexander Simonov f7949596eb Fix #143 2014-03-18 15:09:50 +02:00
Alexander Simonov 57482232da Version bump 2014-03-16 19:29:15 +02:00
Jeremy Stanley b0b46a5b37 only write zip64 central directory if zip64 support enabled 2014-03-13 10:48:04 -06:00
Jeremy Stanley 9e144061b9 fix modifying existing zipfile with zip64 enabled
The local header size computed from the central directory entry
is incorrect due to the Zip64Placeholder in the local entry.
This caused us to seek to the wrong location when copying an
unchanged compressed data stream.

(The same problem could occur when modifying any zip file where
the local header and central directory header contain different
variable-sized fields, so it's a good idea not to trust the CD
to tell us the local header size in any case.)
2014-03-12 15:57:52 -06:00
Zac Stewart 192f910992 Use string concatenation instead of String#prepend
For < Ruby 1.9.3 compatibility
2014-03-12 11:52:12 -04:00
Zac Stewart 96377f72de Add InputStream#ungetc
Works like IO#ungetc
2014-03-11 21:19:24 -04:00
Alexander Simonov 2697c7ea4f Fix #138 2014-03-09 20:38:24 +02:00
Alexander Simonov 34437e77b8 Fix for #125 2014-03-01 12:17:22 +02:00
Alexander Simonov 81c4c4face Fix #135 2014-03-01 00:31:10 +02:00
Alexander Simonov 09ac194540 Merge pull request #130 from srawlins/less-allocations-writing-a-zipfile
Allocate less Arrays and Strings when writing a zip
2014-02-07 09:05:34 +02:00
Sam Rawlins a37e13c6f0 File.exists? -> File.exist? 2014-02-06 15:00:38 -08:00
Henry Yang a800987a52 Speed up Deflater sysread speed when number_of_bytes is small and @output_buffer is large 2014-02-04 10:56:56 -08:00
Sam Rawlins a68a36c759 Allocate less Arrays and Strings when writing a zip 2014-02-03 12:15:08 -08:00
Alexander Simonov ec81c30382 Fix for #126 and #127 2014-01-24 11:37:38 +02:00
René Sprotte 471aa1599e Add config to set the default compression level. 2014-01-20 14:38:22 +01:00
Alexander Simonov 52efd5cd61 Fix tests. Fix duping StringIO for writing 2014-01-19 14:06:54 +02:00
Alexander Simonov c7f0b17abf Real fix for #119 2014-01-19 13:45:58 +02:00
Alexander Simonov 18506c6345 Fix #119 calling 'path' on not IO objects 2014-01-06 20:29:39 +02:00
Jim Ryan 0f8ce2cbb8 Make File.open_buffer support Tempfiles 2013-12-02 18:57:42 -05:00
Alexander Simonov 3917dedbb5 Version bump 2013-11-01 16:36:25 +02:00
Alexander Simonov 94b29aba5d Fix #106 Set options about restoring ownerships, permissions and times. restore permissions enabled by default. 2013-10-27 16:30:48 +02:00
Alexander Simonov cb6e628fb2 Fix #28 and #103 2013-10-20 23:09:52 +03:00
Alexander Simonov 9c25518761 Merge pull request #101 from ProGNOMmers/issue_100
Add entry arguments to Zip::File#get_output_stream. Fixes rubyzip/rubyzip#100
2013-10-19 12:35:09 -07:00
Alexander Simonov 569d0b7078 Fix #102 recover file permissions if zip file was exist 2013-10-19 22:05:18 +03:00
Maurizio De Santis bc512d7061 Add missing Zip::Entry arguments to Zip::File#get_output_stream. Fixes rubyzip/rubyzip#100 2013-10-11 11:40:44 +02:00
Alexander Simonov d1aba72c03 Merge pull request #99 from jstanley0/master
Add read/write support for zip64 extensions
2013-09-27 23:41:56 -07:00
Jeremy Stanley b87c95cc7e fix string encoding of zip64 header ids for ruby 2.0 2013-09-27 21:45:08 -06:00
Jeremy Stanley af165f5cbd Add read/write support for zip64 extensions
This commit adds the capability of creating archives larger than
4GB via zip64 extensions. It also fixes bugs reading archives of
this size (specifically, the 64-bit offset of the local file
header was not being read from the central directory entry).

To maximize compatibility, zip64 extensions are used only when
required. Unfortunately, at the time we write a local file header,
we don't know the size of the file and thus whether a Zip64
Extended Information Extra Field will be required. Therefore
this commit writes a 'placeholder' extra field to reserve space
for the zip64 entry, which will be written if necessary when
we update the local entry with the final sizes and CRC. I use
the signature "\x99\x99" for this field, following the example
of DotNetZip which does the same.

This commit also adds a rake task, zip64_full_test, which
fully tests zip64 by actually creating and verifying a 4GB zip
file. Please note, however, that this test requires UnZip
version 6.00 or newer, which may not be supplied by your OS.
This test doesn't run along with the main unit tests because
it takes a few minutes to complete.
2013-09-27 20:41:00 -06:00
Alexander Simonov 0402911595 Better jRuby support 2013-09-25 21:02:02 +03:00
Alfredo Amatriain fc86984e3c Fixed rdoc comments in filesystem.rb to account for API changes in Rubyzip 1.0.0 2013-09-25 11:40:35 +02:00
Krishna Dole 8d3258eebf Calling #read(number_of_bytes) on a Zip::InputStream should return nil at EOF.
Previously it would return an empty string the first time, then raise on subsequent calls.
2013-09-24 15:29:19 -07:00
Alexander Simonov 2bd6ebea11 JRuby support 2013-09-17 20:34:19 +03:00
Nick Markwell d7091a0271 Typo fix: io.is_a() -> io.is_a?() 2013-09-06 12:20:06 -04:00
Nick Markwell 9f6bc1e2e9 Fixed conditional in Zip::File.open_buffer()
It required it to be be both an IO _and_ a String, which isn't exactly possible.
2013-09-06 12:06:19 -04:00
Alexander Simonov 5f2411955a Fix tests for 1.9.2 2013-08-30 00:22:19 +03:00
Alexander Simonov 73d9e1c8a0 StingIO support #47 #18 2013-08-29 23:50:12 +03:00
Alexander Simonov 72d20297fc Version bump 2013-08-29 10:46:39 +03:00
Alexander Simonov 609de2ff48 Zip64 read-only support. Fix #81 2013-08-26 23:26:14 +03:00
Alexander Simonov 8b92e40227 Version bump 2013-08-22 00:39:52 +03:00
Alexander Simonov 317fdd0d04 Add posibility to set Language encoding flag. Changed way to set settings. 2013-08-15 01:00:27 +03:00
Jason King 8d912fb5de Unset @create when zip exists, fixes #86 2013-07-31 17:31:07 -07:00
Alexander Simonov 51fb507e2a Split functions small cleanup 2013-07-01 00:11:45 +03:00
Alexander Simonov 531003c44f Remove unneeded monkey patch 2013-06-30 23:57:06 +03:00
Alexander Simonov 20d79feb99 Refactor ::Zip::Entry and ::Zip::ExtraField 2013-06-30 23:52:48 +03:00
Alexander Simonov b0f41a55f9 Refactoring of split method 2013-06-03 13:36:45 +03:00
Alexander Simonov 61ce5dbc5f Refactoring part #2
Rubyzip interface was changed!
2013-06-03 10:56:24 +03:00
Alexander Simonov 974f5675c2 Code refactoring start 2013-06-02 21:33:03 +03:00
Alexander Simonov ce2c3ede73 Fix merge 2013-04-13 13:26:20 +03:00
Alexander Simonov 85e6468180 Merge pull request #75 from hbakhtiyor/split-archive-feature
Split archive feature
2013-04-13 01:58:23 -07:00
Alexander Simonov 69f5d65cf2 Merge pull request #77 from kachick/improve-remove_warnings2
Remove some interpreter warnings
2013-04-13 01:54:42 -07:00
Abd ar-Rahman Hamidi 5604881648 Add ZipFile.split method for spliting an archive into parts with chunk size. With samples and test cases 2013-04-07 18:29:33 +05:00
Kenichi Kamiya 6d5fc4144b Fix typo 2013-04-03 23:50:54 +09:00
Kenichi Kamiya 00c104c567 Rename unused variable
This commit removes below interpreter warning.

* warning: assigned but unused variable
2013-04-03 23:46:41 +09:00
Alexander Simonov 66f0c0fafe Merge pull request #65 from marcuserronius/preserve-order
preserves order of zipfile entries
2013-02-07 00:55:28 -08:00
Alexander Simonov fbafce3328 Merge pull request #64 from rap-kasta/master
Averting of compression method override
2013-02-07 00:53:55 -08:00
Alexander Simonov 9f46091456 Merge pull request #67 from JustinLove/getslimit
support gets-with-limit from ruby 1.9
2013-02-07 00:48:38 -08:00
Alexander Simonov e519cc7f61 Merge pull request #68 from Wolfer/patch-1
use Object::File
2013-02-07 00:48:04 -08:00
dismory 4403cc089e Using `FileUtils.mkdir_p` for intermediate directories as required 2013-01-09 17:52:57 +08:00
Serg F 23a63f6786 use Object::File
may be run Zip::File and conflict with other zip library.
2012-12-17 01:14:39 +04:00
Justin Love 11df150531 support gets-with-limit from ruby 1.9 2012-12-07 20:53:22 -06:00
Mark Hubbart 31259bb416 preserves order of zipfile entries
Makes ZipEntrySet preserve the original order of files in the zipfile.
Also preserves the insertion order of files.
2012-10-19 12:24:02 -07:00
rap-kasta 1ee0f16183 Averting of compression method override 2012-09-14 13:52:20 +06:00
Justin Love 3406ad49cd read boundaries could break a multi-character gets terminator 2012-08-29 19:11:23 -05:00
Justin Love d45d656353 Merge branch 'master' into pos 2012-07-05 13:56:26 -05:00
Alexander Simonov 023ff8497e Remove unused require 2012-06-17 23:44:22 +03:00
Alexander Simonov f9d390496a Fix #1 2012-06-17 23:35:38 +03:00
Alexander Simonov 4e8b20f32b Fix #53 again... 2012-06-17 23:12:56 +03:00
Alexander Simonov 381355f216 Fix #53 2012-06-17 20:10:34 +03:00
Alex Dowad e14859a979 Added Zip::ZipFile.open_buffer 2012-05-21 12:21:12 +03:00
Alexander Simonov dbc0213633 Merge pull request #48 from yaauie/feature/glob
Add ZipFile#glob and ZipFileSystem#glob
2012-05-19 01:36:59 -07:00
Ryan Biesemeyer 739b352f32 add glob support in ZipFile and ZipFileSystem, refactor existing ZipEntrySet#glob to accept block and be more memory efficient with results. 2012-05-18 21:57:19 +00:00
Bernie Telles bb53c0aff4 manually require NullInputStream, otherwise it doesn't get recognized 2012-04-26 13:04:30 -07:00
Julien Ammous 07068d1134 bugfix: get correct size for utf8 strings 2012-04-12 12:01:40 +02:00
Alexander Simonov daa21eb85e Version bump 2012-04-08 00:21:02 +03:00
Dylan Markow c60520f299 Properly commit when the comment is the only thing changed. 2012-04-06 16:40:21 -07:00
Alexander Simonov 82c2037cf6 Merge pull request #40 from edouard/keep_entry_mtime
ZipEntry modification time isn’t saved in zip file
2012-03-27 02:50:38 -07:00
Édouard Brière 9268fefaf1 Fix: ZipOutputStream#put_next_entry now keeps entry modification time 2012-03-27 11:31:13 +02:00
wpc d33d8c2398 Fix performance issue on ZipFile#find_entry when reading/writing zip
file with large amount of files and directories.
2012-03-26 00:05:06 -07:00
Alexander Simonov 2faee060f8 Fix #29 2012-03-13 10:26:51 +02:00
Alexander Simonov 7205983957 Refactoring 2012-03-13 10:14:57 +02:00
Alexander Simonov f9b9a30b6f Refactoring 2012-03-13 10:13:58 +02:00
Alexander Simonov 6712879287 Merge pull request #31 from Fuzion24/master
Unzipping fails when file attributes are 0
2012-03-13 01:06:36 -07:00
Alexander Simonov dfca45d4b0 Merge pull request #32 from jsanders/namespace_dos_time
Add Zip namespace to DOSTime class
2012-03-13 01:04:53 -07:00
kellydunn 7830a83b52 [lib][test] Renaming option for simplicity 2012-03-12 16:34:50 -07:00
kellydunn 1de6e2b73c [lib][settings] Renaming options for clearer description of implementation 2012-03-12 13:45:02 -07:00
kellydunn 32f02579d0 [lib] Requiring settings upon init, revising implementation. 2012-03-12 13:39:46 -07:00
kellydunn db70959751 [settings] Adding in settings.rb 2012-03-12 13:34:35 -07:00
James Sanders ab99778c37 Add Zip namespace to DOSTime class
In the top level, it conflicts with the archive-zip library's class of
the same name.
2012-03-01 10:30:49 -07:00
Ryan Welton 8c45c67a86 A zip file with externalFileAttributes == 0 causes unknown filetype... 2012-02-28 15:44:15 -05:00
KOJIMA Satoshi 963f23c9ed do not sort entries on ZipCentralDirectory#write_io_stream 2012-02-19 22:34:50 +09:00
Lucas Hills c68770f3a3 Added better support for ruby187 mingw developers 2012-02-06 11:59:11 +11:00
Lucas Hills 183deb7be0 Fixed replace method 2012-02-06 11:57:06 +11:00
Lucas Hills 26ec16866e mingw ruby187 does not recognise utf8 2012-02-06 11:52:27 +11:00
Jean Boussier 85054091e8 Get rid of Time extensions 2012-02-01 11:16:13 +01:00
Jean Boussier 219b853412 Get rid of String#lchop 2012-02-01 11:10:34 +01:00
Jean Boussier dc159646e6 Get rid of String#ensure_end 2012-02-01 10:59:56 +01:00
Jean Boussier a92b601f98 Get rid of unused Enumerable#select_map 2012-02-01 10:48:25 +01:00
Jean Boussier 1b777ef184 Get rid of Module#forward_message 2012-02-01 10:47:17 +01:00
Alexander Simonov 028262700e Rubyzip and Zipruby conflict Fix #6 2012-01-31 21:46:42 +02:00
KOJIMA Satoshi 1625f76265 added ZipInputStream::open_buffer 2012-01-26 22:50:25 +09:00
Justin Love 8d53a0197a support pos for CSV line ending auto detection and progress tracking 2012-01-02 10:48:07 -06:00
Alexander Simonov 3418d31b44 Code cleanup 2011-11-17 22:53:04 +02:00
Alexander Simonov 7cb60f5a37 Fix for UTF-8 filenames 2011-11-17 22:28:44 +02:00
Alexander Simonov 9aa578e487 Fix constants 2011-11-17 22:27:26 +02:00
alor 16b6400a12 code cleanup 2011-11-17 13:29:44 +01:00
alor bb7c918dec don't make chown dirty (not my job) 2011-11-17 11:11:45 +01:00
alor 4f9595c23b open() can accept permissions
chown() is now working by setting the dirty flag
commit_required? returns true if at least one ZipEntry is dirty
2011-11-17 10:48:42 +01:00
alor 7be1b9c55a indent to spaces 2011-11-16 16:17:19 +01:00
alor b89aeb71df indent to spaces 2011-11-16 16:11:18 +01:00
alor a354ea08dc indent to spaces 2011-11-16 16:09:14 +01:00
alor 8610ec9eec correct code indentation 2011-11-16 16:04:28 +01:00
Xavier Shay 9116110cfe Don't use iconv on 1.9, use native encodings instead. 2011-11-14 18:50:42 +11:00
Xavier Shay ec04e20b21 Extract constants into a file to avoid redefinition (and associated warnings) 2011-11-14 18:48:34 +11:00
Alan Harper 446c114b75 Split version out in to useful constant 2011-10-05 07:49:33 +11:00
Alan Harper 43e6a5a06c Merge pull request #7 from alown/master
Sort Central Directory
2011-09-21 14:53:48 -07:00
Alan Harper a3c72e7127 Merge pull request #5 from dmgarland/master
Escape Regex to allow characters such as parentheses into filenames
2011-09-21 14:50:45 -07:00
Alan Harper 794c9463fc Removed support for loading ruby in zip files 2011-09-21 22:46:54 +10:00
Ali Lown 74e4512387 Sort before commiting Central Directory
-Fixes an issue I had by ensuring that it unzips in the correct order!
2011-06-11 22:42:38 +01:00
Daniel M Garland 0e83e30940 Escaping the path to allow for characters such as brackets within zip paths. 2011-02-01 11:47:24 +00:00
Alan Harper 0a326dce2b Merge branch 'master' of https://github.com/LyagushkaLimited/rubyzip into LyagushkaLimited-master
* 'master' of https://github.com/LyagushkaLimited/rubyzip:
  Added Support for write data to bugger using ZipFile.add_buffer do {|zf| ... } => buffer
2011-01-07 23:23:22 +10:00
Alan Harper 8f64fe1035 Revert "Started converting to RSpec"
This reverts commit c36359d612.
2011-01-07 22:59:51 +10:00
David Henry 13d5f6c46d Added Support for write data to bugger using ZipFile.add_buffer do {|zf| ... } => buffer 2010-12-06 10:00:03 +00:00
Alan Harper c36359d612 Started converting to RSpec 2010-11-30 23:11:30 +10:00
Alan Harper cd038ae442 Split Zip module up by class in to seperate files 2010-11-30 18:27:59 +10:00
thomas 3bf664c07f Don't react to strongly on incorrect encoding of external file attributes. 2010-09-10 19:56:37 +00:00
thomas a4dc121af5 *** empty log message *** 2010-05-14 20:19:08 +00:00
thomas b2d9f49052 Better platform check. 2010-04-19 08:44:43 +00:00
thomas 13b7856858 ruby-1.9.1 compatibility patch from Tatsuki Sugiura. 2010-02-25 12:24:48 +00:00
thomas d0faedc82b Changed ZipOutputStream.put_next_entry to make it possible to specifiy comments, extra field and compression method. 2010-01-01 12:43:52 +00:00
thomas 6e840960c4 Bumped micro number and updated NEWS file. 2009-11-27 21:59:43 +00:00
thomas 4221a5d2eb Provide convenience methods for retrieving name and comments in character encoding of choice (pending ruby character String class). 2009-11-27 21:28:18 +00:00
thomas c6ecd1c9f3 Applied ruby-1.9 compatibility patch from Yuya Nishida. 2009-04-05 10:28:46 +00:00
thomas 426d65cca7 Rewrote fix for rename bug. 2008-08-26 18:49:27 +00:00
thomas 51c56a1fb8 Refixed rename to avoid decompressing and recompressing entry. 2008-08-24 12:34:20 +00:00
drylight 34cfcfe78e Update version number and minor release note changes. 2008-08-24 09:43:33 +00:00
drylight 9c5b55e5da Fixed: Renaming an entry failed if the entry's new name was a different length than its old name. 2008-08-24 08:46:45 +00:00
thomas f3877622d3 Added IOExtras.copy_stream_n and used it to avoid loading large entries into memory when copying from one stream to another. 2006-12-24 10:42:08 +00:00
thomas 486ae7d07b Bug 1614537 Version needed to extract set. 2006-12-17 14:03:36 +00:00
thomas 73c47965c3 Bug 1600222 Fixed it so ZipFsFile#open accepts and ignores b(inary) option. 2006-11-21 08:12:13 +00:00
technorama fda12b16da bugfix: :link -> :symlink 2006-08-04 17:56:22 +00:00