From 3e895adbab8a9a44e9a0aa0fe2557797b8cd34ed Mon Sep 17 00:00:00 2001 From: Moon Sungjoon Date: Mon, 26 Jun 2023 18:21:53 +0900 Subject: [PATCH] Add hwp hwpx support hwp/hwpx has several custom MIME types .hwp: - application/x-hwp - application/haansofthwp - application/vnd.hancom.hwp .hwpx: - application/haansofthwpx - application/vnd.hancom.hwpx, - application/hwp+zip Fixes #243 --- Dockerfile | 3 ++- README.md | 1 + dangerzone/conversion/doc_to_pixels.py | 20 ++++++++++++++++++++ dangerzone/gui/main_window.py | 2 +- install/pyinstaller/pyinstaller.spec | 14 ++++++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f8c79f0..78b2926 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,8 @@ RUN apk --no-cache -U upgrade && \ poppler-data \ python3 \ py3-magic \ - tesseract-ocr + tesseract-ocr \ + font-noto-cjk # Download the trained models from the latest GitHub release of Tesseract, and # store them under /usr/share/tessdata. This is basically what distro packages diff --git a/README.md b/README.md index d443ab4..1f45faf 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Dangerzone can convert these types of document into safe PDFs: - ODF Spreadsheet (`.ods`) - ODF Presentation (`.odp`) - ODF Graphics (`.odg`) +- Hancom HWP (Hangul Word Processor) (`.hwp`, `.hwpx`) - Jpeg (`.jpg`, `.jpeg`) - GIF (`.gif`) - PNG (`.png`) diff --git a/dangerzone/conversion/doc_to_pixels.py b/dangerzone/conversion/doc_to_pixels.py index 2151500..ac6055a 100644 --- a/dangerzone/conversion/doc_to_pixels.py +++ b/dangerzone/conversion/doc_to_pixels.py @@ -77,6 +77,26 @@ class DocumentToPixels(DangerzoneConverter): "application/vnd.oasis.opendocument.text-template": { "type": "libreoffice", }, + # .hwp + "application/vnd.hancom.hwp": { + "type": "libreoffice", + }, + "application/haansofthwp": { + "type": "libreoffice", + }, + "application/x-hwp": { + "type": "libreoffice", + }, + # .hwpx + "application/vnd.hancom.hwpx": { + "type": "libreoffice", + }, + "application/haansofthwpx": { + "type": "libreoffice", + }, + "application/hwp+zip": { + "type": "libreoffice", + }, # At least .odt, .docx, .odg, .odp, .ods, and .pptx "application/zip": { "type": "libreoffice", diff --git a/dangerzone/gui/main_window.py b/dangerzone/gui/main_window.py index 1aac928..71a7c14 100644 --- a/dangerzone/gui/main_window.py +++ b/dangerzone/gui/main_window.py @@ -553,7 +553,7 @@ class DocSelectionWidget(QtWidgets.QWidget): self.file_dialog.setFileMode(QtWidgets.QFileDialog.ExistingFiles) self.file_dialog.setNameFilters( [ - "Documents (*.pdf *.docx *.doc *.docm *.xlsx *.xls *.pptx *.ppt *.odt *.odg *.odp *.ods *.jpg *.jpeg *.gif *.png *.tif *.tiff)" + "Documents (*.pdf *.docx *.doc *.docm *.xlsx *.xls *.pptx *.ppt *.odt *.odg *.odp *.ods *.hwp *.hwpx *.jpg *.jpeg *.gif *.png *.tif *.tiff)" ] ) diff --git a/install/pyinstaller/pyinstaller.spec b/install/pyinstaller/pyinstaller.spec index f8d2380..186b1d2 100644 --- a/install/pyinstaller/pyinstaller.spec +++ b/install/pyinstaller/pyinstaller.spec @@ -143,6 +143,20 @@ if p == "Darwin": "CFBundleTypeName": "ODF Graphics Document", "CFBundleTypeRole": "Viewer", }, + { + "CFBundleTypeExtensions": ["hwp", "hwpx"], + "CFBundleTypeIconFile": "../macos/document.icns", + "CFBundleTypeMIMETypes": [ + "application/vnd.hancom.hwp", + "application/haansofthwp", + "application/x-hwp", + "application/vnd.hancom.hwpx", + "application/haansofthwpx", + "application/hwp+zip", + ], + "CFBundleTypeName": "Hancom Office Document", + "CFBundleTypeRole": "Viewer", + }, { "CFBundleTypeExtensions": ["jpg", "jpeg"], "CFBundleTypeIconFile": "../macos/document.icns",