mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: misc fixes
This commit is contained in:
parent
1a602a7873
commit
eced0f25b3
@ -1322,8 +1322,8 @@ class OPF(object): # {{{
|
|||||||
if pretty_print_opf:
|
if pretty_print_opf:
|
||||||
_pretty_print(self.root)
|
_pretty_print(self.root)
|
||||||
raw = etree.tostring(self.root, encoding=encoding, pretty_print=True)
|
raw = etree.tostring(self.root, encoding=encoding, pretty_print=True)
|
||||||
if not raw.lstrip().startswith('<?xml '):
|
if not raw.lstrip().startswith(b'<?xml '):
|
||||||
raw = '<?xml version="1.0" encoding="%s"?>\n'%encoding.upper()+raw
|
raw = ('<?xml version="1.0" encoding="%s"?>\n'%encoding.upper()).encode('ascii') + raw
|
||||||
return raw
|
return raw
|
||||||
|
|
||||||
def smart_update(self, mi, replace_metadata=False, apply_null=False):
|
def smart_update(self, mi, replace_metadata=False, apply_null=False):
|
||||||
|
@ -321,7 +321,7 @@ class ZipInfo (object):
|
|||||||
|
|
||||||
# Terminate the file name at the first null byte. Null bytes in file
|
# Terminate the file name at the first null byte. Null bytes in file
|
||||||
# names are used as tricks by viruses in archives.
|
# names are used as tricks by viruses in archives.
|
||||||
null_byte = filename.find(chr(0))
|
null_byte = filename.find(b'\0' if isinstance(filename, bytes) else u'\0')
|
||||||
if null_byte >= 0:
|
if null_byte >= 0:
|
||||||
filename = filename[0:null_byte]
|
filename = filename[0:null_byte]
|
||||||
# This is used to ensure paths in generated ZIP files always use
|
# This is used to ensure paths in generated ZIP files always use
|
||||||
|
Loading…
x
Reference in New Issue
Block a user