diff --git a/README.md b/README.md index 7254a9c..8e1cd10 100644 --- a/README.md +++ b/README.md @@ -54,9 +54,12 @@ Dangerzone can convert these types of document into safe PDFs: - Hancom HWP (Hangul Word Processor) (`.hwp`, `.hwpx`) * Not supported on [Qubes OS](https://github.com/freedomofpress/dangerzone/issues/494) +- EPUB (`.epub`) - Jpeg (`.jpg`, `.jpeg`) - GIF (`.gif`) - PNG (`.png`) +- SVG (`.svg`) +- other image formats (`.bmp`, `.pnm`, `pbm`, `ppm`) Dangerzone was inspired by [Qubes trusted PDF](https://blog.invisiblethings.org/2013/02/21/converting-untrusted-pdfs-into-trusted.html), but it works in non-Qubes operating systems. It uses containers as sandboxes instead of virtual machines (using Docker for macOS and Windows, and [podman](https://podman.io/) on Linux). diff --git a/dangerzone/conversion/doc_to_pixels.py b/dangerzone/conversion/doc_to_pixels.py index 38e437a..9d5b79b 100644 --- a/dangerzone/conversion/doc_to_pixels.py +++ b/dangerzone/conversion/doc_to_pixels.py @@ -145,6 +145,18 @@ class DocumentToPixels(DangerzoneConverter): "application/x-ole-storage": { "type": "libreoffice", }, + # .epub + "application/epub+zip": {"type": "PyMuPDF"}, + # .svg + "image/svg+xml": {"type": "PyMuPDF"}, + # .bmp + "image/bmp": {"type": "PyMuPDF"}, + # .pnm + "image/x-portable-anymap": {"type": "PyMuPDF"}, + # .pbm + "image/x-portable-bitmap": {"type": "PyMuPDF"}, + # .ppm + "image/x-portable-pixmap": {"type": "PyMuPDF"}, # .jpg "image/jpeg": {"type": "PyMuPDF"}, # .gif diff --git a/dangerzone/gui/main_window.py b/dangerzone/gui/main_window.py index fd05a73..6b23f6a 100644 --- a/dangerzone/gui/main_window.py +++ b/dangerzone/gui/main_window.py @@ -562,7 +562,7 @@ class DocSelectionWidget(QtWidgets.QWidget): hwp_filters = "" self.file_dialog.setNameFilters( [ - f"Documents (*.pdf *.docx *.doc *.docm *.xlsx *.xls *.pptx *.ppt *.odt *.odg *.odp *.ods {hwp_filters} *.jpg *.jpeg *.gif *.png *.tif *.tiff)" + f"Documents (*.pdf *.docx *.doc *.docm *.xlsx *.xls *.pptx *.ppt *.odt *.odg *.odp *.ods {hwp_filters} *.epub *.jpg *.jpeg *.gif *.png *.tif *.tiff *.bpm *.pnm *.pbm *.ppm)" ] ) diff --git a/install/linux/press.freedom.dangerzone.desktop b/install/linux/press.freedom.dangerzone.desktop index 7469975..b3d0734 100644 --- a/install/linux/press.freedom.dangerzone.desktop +++ b/install/linux/press.freedom.dangerzone.desktop @@ -7,4 +7,4 @@ Terminal=false Type=Application Icon=press.freedom.dangerzone Categories=Office;Utility;OCR;Security -MimeType=application/pdf;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/msword;application/vnd.ms-word.document.macroEnabled.12;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.ms-powerpoint;application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.graphics;application/vnd.oasis.opendocument.presentation;application/vnd.oasis.opendocument.spreadsheet;image/jpeg;image/gif;image/png;image/tiff;image/x-tiff +MimeType=application/pdf;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/msword;application/vnd.ms-word.document.macroEnabled.12;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.ms-powerpoint;application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.graphics;application/vnd.oasis.opendocument.presentation;application/vnd.oasis.opendocument.spreadsheet;application/epub+zip;application/x-mobipocket-ebook;image/svg+xml;image/bmp;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-pixmap;image/jpeg;image/gif;image/png;image/tiff;image/x-tiff diff --git a/install/pyinstaller/pyinstaller.spec b/install/pyinstaller/pyinstaller.spec index cc74d3d..9802743 100644 --- a/install/pyinstaller/pyinstaller.spec +++ b/install/pyinstaller/pyinstaller.spec @@ -160,6 +160,48 @@ if p == "Darwin": "CFBundleTypeName": "Hancom Office Document", "CFBundleTypeRole": "Viewer", }, + { + "CFBundleTypeExtensions": ["epub"], + "CFBundleTypeIconFile": "../macos/document.icns", + "CFBundleTypeMIMETypes": ["application/epub+zip"], + "CFBundleTypeName": "EPUB document", + "CFBundleTypeRole": "Viewer", + }, + { + "CFBundleTypeExtensions": ["svg"], + "CFBundleTypeIconFile": "../macos/document.icns", + "CFBundleTypeMIMETypes": ["image/svg+xml"], + "CFBundleTypeName": "SVG Image", + "CFBundleTypeRole": "Viewer", + }, + { + "CFBundleTypeExtensions": ["bmp"], + "CFBundleTypeIconFile": "../macos/document.icns", + "CFBundleTypeMIMETypes": ["image/bmp"], + "CFBundleTypeName": "BMP Image", + "CFBundleTypeRole": "Viewer", + }, + { + "CFBundleTypeExtensions": ["pbm"], + "CFBundleTypeIconFile": "../macos/document.icns", + "CFBundleTypeMIMETypes": ["image/x-portable-bitmap"], + "CFBundleTypeName": "PBM Image", + "CFBundleTypeRole": "Viewer", + }, + { + "CFBundleTypeExtensions": ["ppm"], + "CFBundleTypeIconFile": "../macos/document.icns", + "CFBundleTypeMIMETypes": ["image/x-portable-pixmap"], + "CFBundleTypeName": "PPM Image", + "CFBundleTypeRole": "Viewer", + }, + { + "CFBundleTypeExtensions": ["pnm"], + "CFBundleTypeIconFile": "../macos/document.icns", + "CFBundleTypeMIMETypes": ["image/x-portable-anymap"], + "CFBundleTypeName": "PNM Image", + "CFBundleTypeRole": "Viewer", + }, { "CFBundleTypeExtensions": ["jpg", "jpeg"], "CFBundleTypeIconFile": "../macos/document.icns", diff --git a/tests/test_docs/sample-bmp.bmp b/tests/test_docs/sample-bmp.bmp new file mode 100644 index 0000000..dca58a3 Binary files /dev/null and b/tests/test_docs/sample-bmp.bmp differ diff --git a/tests/test_docs/sample-epub.epub b/tests/test_docs/sample-epub.epub new file mode 100644 index 0000000..1edea4c Binary files /dev/null and b/tests/test_docs/sample-epub.epub differ diff --git a/tests/test_docs/sample-pbm.pbm b/tests/test_docs/sample-pbm.pbm new file mode 100644 index 0000000..728eb9e Binary files /dev/null and b/tests/test_docs/sample-pbm.pbm differ diff --git a/tests/test_docs/sample-pnm.pnm b/tests/test_docs/sample-pnm.pnm new file mode 100644 index 0000000..d66a189 Binary files /dev/null and b/tests/test_docs/sample-pnm.pnm differ diff --git a/tests/test_docs/sample-ppm.ppm b/tests/test_docs/sample-ppm.ppm new file mode 100644 index 0000000..d66a189 Binary files /dev/null and b/tests/test_docs/sample-ppm.ppm differ diff --git a/tests/test_docs/sample-svg.svg b/tests/test_docs/sample-svg.svg new file mode 100644 index 0000000..12edc72 --- /dev/null +++ b/tests/test_docs/sample-svg.svg @@ -0,0 +1,300 @@ + +