Skip to content

Commit

Permalink
resolves #281 prevent document from overriding epubcheck/kindlegen pa…
Browse files Browse the repository at this point in the history
…th attributes
  • Loading branch information
slonopotamus committed Mar 3, 2020
1 parent 09b7b76 commit 77b64ec
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 @@ -12,6 +12,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
* add xref ids to paragraphs (#317)
* support syntax highlighting with CodeRay and Rouge (#262)
* pygments.rb is no longer auto-activated
* prevent document from overriding epubcheck/kindlegen path attributes (#281)

== 1.5.0.alpha.14 (2020-02-29) - @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 @@ -97,6 +97,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['epubcheck-path'] ||= nil
attr_overrides['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 @@ -192,5 +192,19 @@
expect(book.publisher).not_to be_nil
expect(book.publisher.content).to eq('MyProducer')
end

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

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

0 comments on commit 77b64ec

Please sign in to comment.