diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2efe7e9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Mark EPUB files as binary to prevent any text transformations +*.epub binary diff --git a/dreader/managers/document.py b/dreader/managers/document.py index bcf66be..3c75067 100644 --- a/dreader/managers/document.py +++ b/dreader/managers/document.py @@ -70,6 +70,9 @@ class DocumentManager: except Exception as e: print(f"Error loading EPUB: {e}") + import traceback + print(f"Full traceback:") + traceback.print_exc() return False def load_html(self, html_string: str, title: str = "HTML Document", diff --git a/tests/data/library-epub/pg5200-images-3.epub b/tests/data/library-epub/pg5200-images-3.epub index 09cd378..8670db9 100644 Binary files a/tests/data/library-epub/pg5200-images-3.epub and b/tests/data/library-epub/pg5200-images-3.epub differ diff --git a/tests/test_settings_overlay.py b/tests/test_settings_overlay.py index d5e8023..9786f0f 100644 --- a/tests/test_settings_overlay.py +++ b/tests/test_settings_overlay.py @@ -48,6 +48,13 @@ class TestSettingsOverlay(unittest.TestCase): # Test if it's a valid ZIP if test_epub.exists(): + # Check file magic bytes + with open(test_epub, 'rb') as f: + first_bytes = f.read(10) + print(f"First 10 bytes (hex): {first_bytes.hex()}") + print(f"First 10 bytes (ascii): {first_bytes[:4]}") + print(f"Is PK header: {first_bytes[:2] == b'PK'}") + try: with zipfile.ZipFile(test_epub, 'r') as zf: print(f"Valid ZIP: True")