Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves #281 prevent document from overriding epubcheck/kindlegen path attributes #320

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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