Skip to content

Commit

Permalink
resolves asciidoctor#281 prevent document from overriding epubcheck/k…
Browse files Browse the repository at this point in the history
…indlegen path attributes
  • Loading branch information
slonopotamus committed Jul 2, 2020
1 parent 12f9f1c commit 63fe31d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
* fix chapter titles to actually be chapter titles instead of document title (#343)
* store syntax highlighter CSS in a separate file (#339)
* initial landmarks support: appendix, bibliography, bodymatter, cover, frontmatter, glossary, index, preface, toc (#174)
* prevent document from overriding epubcheck/kindlegen path attributes (#281)

== 1.5.0.alpha.17 (2020-05-25) - @slonopotamus

Expand Down
9 changes: 9 additions & 0 deletions lib/asciidoctor-epub3/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ def initialize backend, opts = {}
basebackend 'html'
outfilesuffix '.epub' # dummy outfilesuffix since it may be .mobi
htmlsyntax 'xml'

attr_overrides = opts[:document].instance_variable_get :@attribute_overrides
if attr_overrides.nil?
logger.error 'Failed to prevent document from overriding epubcheck/kindlegen path attributes'
else
# Prevent document fro overriding paths to binaries that we execute
attr_overrides['ebook-epubcheck-path'] ||= nil
attr_overrides['ebook-kindlegen-path'] ||= nil
end
end

def convert node, name = nil, _opts = {}
Expand Down
14 changes: 14 additions & 0 deletions spec/converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,5 +328,19 @@
</tr>
EOS
end

it 'prevents document from overriding kindlegen/epubcheck path attributes' do
book = to_epub <<~EOS
= Article
:ebook-kindlegen-path: /evilgen
:ebook-epubcheck-path: /evilcheck
{ebook-epubcheck-path}
{ebook-kindlegen-path}
EOS

article = book.item_by_href '_article.xhtml'
expect(article.content).not_to include('evil')
end
end
end

0 comments on commit 63fe31d

Please sign in to comment.