Adds file formats: epub svg bmp pnm bpm ppm

Partially fix for #660. Missing some files due to limitations [1]:
- PSD - only available from PyMuPDF>=1.23.0 (qubes-fedora is lower)
- TXT - only available from PyMuPDF>=1.23.7 (qubes-fedora is lower)
- JXR - PyMuPDF was refusing to due to missing codec [1]
- JPX - Generated test file was rejected by PyMuPDF [2]
- FB2 - Most often cannot be detected by mime type alone [3]
- CBZ - (idem)
- XPS - (idem)
- MOBI - (idem)
- PAM - General version of other file format already included, so I
  decided not to include this extension [0]

New test files were generated locally:
 - epub - generated with calibre's convert-ebook from another
   sample file
 - svg - generated with inkscape from a mix of a default template
   (hexagons) and a logo's PNG file
 - bmp, pnm, bpm, ppm - generated with ImageMagick's 'convert' from
   tests/test_docs/sample-png.png

[0]: https://github.com/freedomofpress/dangerzone/issues/660#issuecomment-1914681487
[1]: https://github.com/freedomofpress/dangerzone/issues/660#issuecomment-1916803201
[2]: https://github.com/freedomofpress/dangerzone/issues/660#issuecomment-1916870347
[3]: https://github.com/freedomofpress/dangerzone/issues/688
This commit is contained in:
deeplow 2024-01-30 14:17:34 +00:00
parent 4e720aa6e2
commit cd99122385
No known key found for this signature in database
GPG key ID: 577982871529A52A
11 changed files with 359 additions and 2 deletions

View file

@ -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).

View file

@ -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

View file

@ -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)"
]
)

View file

@ -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

View file

@ -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",

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 35 KiB