From 060836c1330dc91bed9e405cf6e80bea49f77843 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 19 Sep 2012 17:43:15 +0530 Subject: [PATCH] AZW3 Output: Do not error out if the input document contains embedded fonts of less than 1040 bytes. Fixes #1052892 (conversion error - epub to azw3 - bytearray index out of range) --- src/calibre/ebooks/mobi/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/mobi/utils.py b/src/calibre/ebooks/mobi/utils.py index ae8e583a1b..09e3055a6e 100644 --- a/src/calibre/ebooks/mobi/utils.py +++ b/src/calibre/ebooks/mobi/utils.py @@ -481,7 +481,7 @@ def write_font_record(data, obfuscate=True, compress=True): if compress: flags |= 0b1 data = zlib.compress(data, 9) - if obfuscate: + if obfuscate and len(data) >= 1040: flags |= 0b10 xor_key = os.urandom(key_len) key = bytearray(xor_key)