mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 23:13:27 +02:00
Partial fix for check book with epub files with non-ascii internal filenames on os x
This commit is contained in:
parent
41520c443d
commit
cad2a50df9
1 changed files with 13 additions and 1 deletions
|
|
@ -7,7 +7,7 @@
|
|||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, logging, sys, hashlib, uuid, re, shutil
|
||||
import os, logging, sys, hashlib, uuid, re, shutil, unicodedata
|
||||
from collections import defaultdict
|
||||
from io import BytesIO
|
||||
from urlparse import urlparse
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
from cssutils import replaceUrls, getUrls
|
||||
|
||||
from calibre import CurrentDir
|
||||
from calibre.constants import isosx
|
||||
from calibre.customize.ui import (plugin_for_input_format,
|
||||
plugin_for_output_format)
|
||||
from calibre.ebooks.chardet import xml_to_unicode
|
||||
|
|
@ -125,6 +126,17 @@ def __init__(self, rootpath, opfpath, log, clone_data=None):
|
|||
for f in filenames:
|
||||
path = join(dirpath, f)
|
||||
name = self.abspath_to_name(path)
|
||||
if isosx:
|
||||
# OS X silently changes all file names to NFD form. The
|
||||
# EPUB spec requires all text including filenames to be in
|
||||
# NFC form. The proper fix is to implement a VFS that maps
|
||||
# between canonical names and their filesystem
|
||||
# representation, however, I dont have the time for that
|
||||
# now, so this will at least fix the problem for books that
|
||||
# properly use the NFC form. Books that use the NFD form
|
||||
# will be broken by this, but that's the price you pay for
|
||||
# using OS X.
|
||||
name = unicodedata.normalize('NFC', name)
|
||||
self.name_path_map[name] = path
|
||||
self.mime_map[name] = guess_type(path)
|
||||
# Special case if we have stumbled onto the opf
|
||||
|
|
|
|||
Loading…
Reference in a new issue