From 729367771ff0e7b8efec59cd6173536e8e411002 Mon Sep 17 00:00:00 2001 From: Marat Radchenko Date: Thu, 12 Mar 2020 22:07:12 +0300 Subject: [PATCH] fix files not being unzipped when 'ebook-extract' attribute is used Unzipping was broken due to fixes for CVE-2018-1000544 in rubyzip: [1], [2]. Also, see [3]. [1]: rubyzip/rubyzip#371 [2]: rubyzip/rubyzip#376 [3]: rubyzip/rubyzip#354 --- lib/asciidoctor-epub3/converter.rb | 2 +- spec/converter_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/asciidoctor-epub3/converter.rb b/lib/asciidoctor-epub3/converter.rb index 144e7b86..ffb1cf4e 100644 --- a/lib/asciidoctor-epub3/converter.rb +++ b/lib/asciidoctor-epub3/converter.rb @@ -30,7 +30,7 @@ def write output, target unless (entry_dir = ::File.dirname entry.name) == '.' || (::File.directory? entry_dir) ::FileUtils.mkdir_p entry_dir end - entry.extract + entry.extract dest_path = entry.name end end end diff --git a/spec/converter_spec.rb b/spec/converter_spec.rb index b3ad1c7c..4cacebf2 100644 --- a/spec/converter_spec.rb +++ b/spec/converter_spec.rb @@ -31,6 +31,12 @@ end end + it 'extracts book when given ebook-extract attribute' do + _, out_file = to_epub fixture_file('minimal/book.adoc'), attributes: { 'ebook-extract' => '' } + out_dir = out_file.dirname + expect(out_dir.join('book', 'EPUB', 'package.opf')).to exist + end + it 'uses current date as fallback when date attributes cannot be parsed' do # TODO: assert that error log contains 'failed to parse revdate' error when we add test infrastructure for logs book, = to_epub fixture_file('minimal/book.adoc'), attributes: { 'revdate' => 'garbage' }