mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 22:43:31 +02:00
py3: misc fixes
This commit is contained in:
parent
1a602a7873
commit
eced0f25b3
2 changed files with 3 additions and 3 deletions
|
|
@ -1322,8 +1322,8 @@ def swap(attr):
|
|||
if pretty_print_opf:
|
||||
_pretty_print(self.root)
|
||||
raw = etree.tostring(self.root, encoding=encoding, pretty_print=True)
|
||||
if not raw.lstrip().startswith('<?xml '):
|
||||
raw = '<?xml version="1.0" encoding="%s"?>\n'%encoding.upper()+raw
|
||||
if not raw.lstrip().startswith(b'<?xml '):
|
||||
raw = ('<?xml version="1.0" encoding="%s"?>\n'%encoding.upper()).encode('ascii') + raw
|
||||
return raw
|
||||
|
||||
def smart_update(self, mi, replace_metadata=False, apply_null=False):
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ def __init__(self, filename=u"NoName", date_time=(1980,1,1,0,0,0)):
|
|||
|
||||
# Terminate the file name at the first null byte. Null bytes in file
|
||||
# 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:
|
||||
filename = filename[0:null_byte]
|
||||
# This is used to ensure paths in generated ZIP files always use
|
||||
|
|
|
|||
Loading…
Reference in a new issue