diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 42a89a3a..ebb7b8d3 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -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 diff --git a/lib/asciidoctor-epub3/converter.rb b/lib/asciidoctor-epub3/converter.rb index 0dbd1e14..99069fb3 100644 --- a/lib/asciidoctor-epub3/converter.rb +++ b/lib/asciidoctor-epub3/converter.rb @@ -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 = {} diff --git a/spec/converter_spec.rb b/spec/converter_spec.rb index 9b746b5c..bc09be40 100644 --- a/spec/converter_spec.rb +++ b/spec/converter_spec.rb @@ -192,5 +192,18 @@ 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 + +{kindlegen-path} + EOS + + article = book.item_by_href '_article.xhtml' + expect(article.content).not_to include('evil') + end end end