From 72fd1567df28a7f247e6a0d81c0c75676abf1523 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 20 Jun 2015 14:06:57 +0530 Subject: [PATCH] Edit Book: Fix smarten punctuation not working for books with non-ascii characters in internal file names on OS X --- src/calibre/ebooks/oeb/polish/container.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/calibre/ebooks/oeb/polish/container.py b/src/calibre/ebooks/oeb/polish/container.py index eea5ade353..6a5ff8f076 100644 --- a/src/calibre/ebooks/oeb/polish/container.py +++ b/src/calibre/ebooks/oeb/polish/container.py @@ -159,15 +159,6 @@ class Container(object): # {{{ for f in filenames: path = join(dirpath, f) name = self.abspath_to_name(path) - # 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 file system representation, however, - # I dont have the time for that now. Note that the container - # ensures that all text files are normalized to NFC when - # decoding them anyway, so there should be no mismatch between - # names in the text and NFC canonical file names. - 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 @@ -373,7 +364,15 @@ class Container(object): # {{{ :param root: The base directory. By default the root for this container object is used. ''' - return abspath_to_name(fullpath, root or self.root) + # 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 file system representation, however, + # I dont have the time for that now. Note that the container + # ensures that all text files are normalized to NFC when + # decoding them anyway, so there should be no mismatch between + # names in the text and NFC canonical file names. + return unicodedata.normalize('NFC', abspath_to_name(fullpath, root or self.root)) def name_to_abspath(self, name): ' Convert a canonical name to an absolute OS dependant path '