Fix #1700. Handle LIT files with URL-encoded filenames in their manifests.

This commit is contained in:
Marshall T. Vandegrift 2009-01-26 12:10:16 -05:00
parent 0350cd79e3
commit cde9d8864c

View File

@ -11,6 +11,7 @@ import sys, struct, cStringIO, os
import functools import functools
import re import re
from urlparse import urldefrag from urlparse import urldefrag
from urllib import unquote as urlunquote
from lxml import etree from lxml import etree
from calibre.ebooks.lit import LitError from calibre.ebooks.lit import LitError
from calibre.ebooks.lit.maps import OPF_MAP, HTML_MAP from calibre.ebooks.lit.maps import OPF_MAP, HTML_MAP
@ -611,6 +612,8 @@ class LitReader(object):
offset, raw = u32(raw), raw[4:] offset, raw = u32(raw), raw[4:]
internal, raw = consume_sized_utf8_string(raw) internal, raw = consume_sized_utf8_string(raw)
original, raw = consume_sized_utf8_string(raw) original, raw = consume_sized_utf8_string(raw)
# The path should be stored unquoted, but not always
original = urlunquote(original)
# Is this last one UTF-8 or ASCIIZ? # Is this last one UTF-8 or ASCIIZ?
mime_type, raw = consume_sized_utf8_string(raw, zpad=True) mime_type, raw = consume_sized_utf8_string(raw, zpad=True)
self.manifest[internal] = ManifestItem( self.manifest[internal] = ManifestItem(