mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 09:52:37 +02:00
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:
parent
4e720aa6e2
commit
cd99122385
11 changed files with 359 additions and 2 deletions
|
@ -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).
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)"
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
BIN
tests/test_docs/sample-bmp.bmp
Normal file
BIN
tests/test_docs/sample-bmp.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 977 KiB |
BIN
tests/test_docs/sample-epub.epub
Normal file
BIN
tests/test_docs/sample-epub.epub
Normal file
Binary file not shown.
BIN
tests/test_docs/sample-pbm.pbm
Normal file
BIN
tests/test_docs/sample-pbm.pbm
Normal file
Binary file not shown.
BIN
tests/test_docs/sample-pnm.pnm
Normal file
BIN
tests/test_docs/sample-pnm.pnm
Normal file
Binary file not shown.
BIN
tests/test_docs/sample-ppm.ppm
Normal file
BIN
tests/test_docs/sample-ppm.ppm
Normal file
Binary file not shown.
300
tests/test_docs/sample-svg.svg
Normal file
300
tests/test_docs/sample-svg.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 35 KiB |
Loading…
Reference in a new issue