Skip to content

Commit 2c6d22e

Browse files
committed
resolves #281 prevent document from overriding epubcheck/kindlegen path attributes
1 parent 09b7b76 commit 2c6d22e

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
1212
* add xref ids to paragraphs (#317)
1313
* support syntax highlighting with CodeRay and Rouge (#262)
1414
* pygments.rb is no longer auto-activated
15+
* prevent document from overriding epubcheck/kindlegen path attributes (#281)
1516

1617
== 1.5.0.alpha.14 (2020-02-29) - @slonopotamus
1718

lib/asciidoctor-epub3/converter.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ def initialize backend, opts = {}
9797
basebackend 'html'
9898
outfilesuffix '.epub' # dummy outfilesuffix since it may be .mobi
9999
htmlsyntax 'xml'
100+
101+
attr_overrides = opts[:document].instance_variable_get :@attribute_overrides
102+
if attr_overrides.nil?
103+
logger.error 'Failed to prevent document from overriding epubcheck/kindlegen path attributes'
104+
else
105+
# Prevent document fro overriding paths to binaries that we execute
106+
attr_overrides['epubcheck-path'] ||= nil
107+
attr_overrides['kindlegen-path'] ||= nil
108+
end
100109
end
101110

102111
def convert node, name = nil, _opts = {}

spec/converter_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,18 @@
192192
expect(book.publisher).not_to be_nil
193193
expect(book.publisher.content).to eq('MyProducer')
194194
end
195+
196+
it 'prevents document from overriding kindlegen/epubcheck path attributes' do
197+
book = to_epub <<~EOS
198+
= Article
199+
:kindlegen-path: /evilgen
200+
:epubcheck-path: /evilcheck
201+
202+
{kindlegen-path}
203+
EOS
204+
205+
article = book.item_by_href '_article.xhtml'
206+
expect(article.content).not_to include('evil')
207+
end
195208
end
196209
end

0 commit comments

Comments
 (0)