EPUB input: Handle books that erroneously set the mimetype for font files to text/plain

This commit is contained in:
Kovid Goyal 2017-12-28 09:19:59 +05:30
parent e9d7975609
commit 9453d87b38
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -294,11 +294,22 @@ class EPUBInput(InputFormatPlugin):
not_for_spine = set() not_for_spine = set()
for y in opf.itermanifest(): for y in opf.itermanifest():
id_ = y.get('id', None) id_ = y.get('id', None)
if id_ and y.get('media-type', None) in { if id_:
'application/vnd.adobe-page-template+xml', 'application/vnd.adobe.page-template+xml', mt = y.get('media-type', None)
'application/adobe-page-template+xml', 'application/adobe.page-template+xml', if mt in {
'application/text'}: 'application/vnd.adobe-page-template+xml',
not_for_spine.add(id_) 'application/vnd.adobe.page-template+xml',
'application/adobe-page-template+xml',
'application/adobe.page-template+xml',
'application/text'
}:
not_for_spine.add(id_)
ext = y.get('href', '').rpartition('.')[-1].lower()
if mt == 'text/plain' and ext in {'otf', 'ttf'}:
# some epub authoring software sets font mime types to
# text/plain
not_for_spine.add(id_)
y.set('media-type', 'application/font')
seen = set() seen = set()
for x in list(opf.iterspine()): for x in list(opf.iterspine()):