Skip to content

Commit

Permalink
fix files not being unzipped when 'ebook-extract' attribute is used
Browse files Browse the repository at this point in the history
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
  • Loading branch information
slonopotamus committed Mar 12, 2020
1 parent d367d5f commit 7293677
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/asciidoctor-epub3/converter.rb
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions spec/converter_spec.rb
Expand Up @@ -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' }
Expand Down

0 comments on commit 7293677

Please sign in to comment.