From 609c12d1c484d04e056dc3e39a47cd45a887f1dd Mon Sep 17 00:00:00 2001 From: taichi Date: Wed, 5 Feb 2020 11:11:46 +0900 Subject: [PATCH 1/4] added Ruby 2.7 to CI regression --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 21a4c64f..b903c3b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ rvm: - 2.4 - 2.5 - 2.6 + - 2.7 - ruby-head matrix: fast_finish: true From 3bc85ccdecfb9be015ecde2227fe9db202c7ea0d Mon Sep 17 00:00:00 2001 From: taichi Date: Wed, 5 Feb 2020 11:30:30 +0900 Subject: [PATCH 2/4] fixed frozen error caseud by frozen string literal --- lib/zip/crypto/decrypted_io.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zip/crypto/decrypted_io.rb b/lib/zip/crypto/decrypted_io.rb index ec9cab8b..362e4a49 100644 --- a/lib/zip/crypto/decrypted_io.rb +++ b/lib/zip/crypto/decrypted_io.rb @@ -7,7 +7,7 @@ def initialize(io, decrypter) @decrypter = decrypter end - def read(length = nil, outbuf = '') + def read(length = nil, outbuf = +'') return ((length.nil? || length.zero?) ? "" : nil) if eof while length.nil? || (buffer.bytesize < length) From b326d1743890b7429472c06403f5294e18d38c34 Mon Sep 17 00:00:00 2001 From: taichi Date: Wed, 5 Feb 2020 11:40:56 +0900 Subject: [PATCH 3/4] use @+ operator instead of #dup to get unfrozen string --- lib/zip/crypto/decrypted_io.rb | 2 +- lib/zip/entry.rb | 2 +- lib/zip/extra_field.rb | 2 +- lib/zip/file.rb | 2 +- lib/zip/inflater.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/zip/crypto/decrypted_io.rb b/lib/zip/crypto/decrypted_io.rb index 362e4a49..1dab17c0 100644 --- a/lib/zip/crypto/decrypted_io.rb +++ b/lib/zip/crypto/decrypted_io.rb @@ -25,7 +25,7 @@ def eof end def buffer - @buffer ||= ''.dup + @buffer ||= +'' end def input_finished? diff --git a/lib/zip/entry.rb b/lib/zip/entry.rb index f1963d8d..a24fb791 100644 --- a/lib/zip/entry.rb +++ b/lib/zip/entry.rb @@ -615,7 +615,7 @@ def create_file(dest_path, _continue_on_exists_proc = proc { Zip.continue_on_exi get_input_stream do |is| bytes_written = 0 warned = false - buf = ''.dup + buf = +'' while (buf = is.sysread(::Zip::Decompressor::CHUNK_SIZE, buf)) os << buf bytes_written += buf.bytesize diff --git a/lib/zip/extra_field.rb b/lib/zip/extra_field.rb index 72c36764..0dcf0d5e 100644 --- a/lib/zip/extra_field.rb +++ b/lib/zip/extra_field.rb @@ -26,7 +26,7 @@ def extra_field_type_unknown(binstr, len, i) end def create_unknown_item - s = ''.dup + s = +'' class << s alias_method :to_c_dir_bin, :to_s alias_method :to_local_bin, :to_s diff --git a/lib/zip/file.rb b/lib/zip/file.rb index 45017822..1479de26 100644 --- a/lib/zip/file.rb +++ b/lib/zip/file.rb @@ -402,7 +402,7 @@ def get_entry(entry) # Creates a directory def mkdir(entryName, permissionInt = 0o755) raise Errno::EEXIST, "File exists - #{entryName}" if find_entry(entryName) - entryName = entryName.dup.to_s + entryName = +entryName.to_s entryName << '/' unless entryName.end_with?('/') @entry_set << ::Zip::StreamableDirectory.new(@name, entryName, nil, permissionInt) end diff --git a/lib/zip/inflater.rb b/lib/zip/inflater.rb index bb735d11..c18f245c 100644 --- a/lib/zip/inflater.rb +++ b/lib/zip/inflater.rb @@ -3,7 +3,7 @@ class Inflater < Decompressor #:nodoc:all def initialize(*args) super - @buffer = ''.dup + @buffer = +'' @zlib_inflater = ::Zlib::Inflate.new(-Zlib::MAX_WBITS) end From 976dbd34081af9b0c8c1970410e787d32fb7cc5c Mon Sep 17 00:00:00 2001 From: taichi Date: Sat, 8 Feb 2020 19:51:47 +0900 Subject: [PATCH 4/4] reverted the change according to comment below: https://github.com/rubyzip/rubyzip/pull/431#discussion_r376698387 --- lib/zip/file.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zip/file.rb b/lib/zip/file.rb index 1479de26..45017822 100644 --- a/lib/zip/file.rb +++ b/lib/zip/file.rb @@ -402,7 +402,7 @@ def get_entry(entry) # Creates a directory def mkdir(entryName, permissionInt = 0o755) raise Errno::EEXIST, "File exists - #{entryName}" if find_entry(entryName) - entryName = +entryName.to_s + entryName = entryName.dup.to_s entryName << '/' unless entryName.end_with?('/') @entry_set << ::Zip::StreamableDirectory.new(@name, entryName, nil, permissionInt) end