Enable HWP conversion on MacOS (Apple silicon CPU)

This PR reverts the patch that disables HWP / HWPX conversion on MacOS M1.
It does not fix conversion on Qubes OS (#494).

Previously, HWP / HWPX conversion didn't work on MacOS (Apple silicon CPU) (#498)
because libreoffice wasn't built with Java support on Alpine Linux for ARM (aarch64).

Gratefully, the Alpine team has enabled Java support on the aarch64
system [1], so we can enable it again for ARM architectures.
And this patch is included in Alpine 3.19

This commit was included in #541 and reverted on #562 due to a stability issue.

Fixes #498

[1]: 74d443f479
This commit is contained in:
Moon Sungjoon 2023-12-08 15:39:59 +08:00 committed by Alex Pyrgiotis
parent bd5b3792e2
commit 63aea4cb45
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA
5 changed files with 9 additions and 17 deletions

View file

@ -7,6 +7,10 @@ since 0.4.1, and this project adheres to [Semantic Versioning](https://semver.or
## Unreleased ## Unreleased
### Changed
- Feature: Add support for HWP/HWPX files (Hancom Office) for macOS Apple Silicon devices ([issue #498](https://github.com/freedomofpress/dangerzone/issues/498), thanks to [@OctopusET](https://github.com/OctopusET))
## Dangerzone 0.5.1 ## Dangerzone 0.5.1
### Fixed ### Fixed

View file

@ -53,8 +53,7 @@ Dangerzone can convert these types of document into safe PDFs:
- ODF Graphics (`.odg`) - ODF Graphics (`.odg`)
- Hancom HWP (Hangul Word Processor) (`.hwp`, `.hwpx`) - Hancom HWP (Hangul Word Processor) (`.hwp`, `.hwpx`)
* Not supported on * Not supported on
[MacOS with Apple Silicon CPU](https://github.com/freedomofpress/dangerzone/issues/498) [Qubes OS](https://github.com/freedomofpress/dangerzone/issues/494)
or [Qubes OS](https://github.com/freedomofpress/dangerzone/issues/494)
- Jpeg (`.jpg`, `.jpeg`) - Jpeg (`.jpg`, `.jpeg`)
- GIF (`.gif`) - GIF (`.gif`)
- PNG (`.png`) - PNG (`.png`)

View file

@ -10,7 +10,6 @@ Here are the steps, with progress bar percentages:
import asyncio import asyncio
import glob import glob
import os import os
import platform
import re import re
import shutil import shutil
import sys import sys
@ -189,13 +188,6 @@ class DocumentToPixels(DangerzoneConverter):
# #
# https://github.com/freedomofpress/dangerzone/issues/494 # https://github.com/freedomofpress/dangerzone/issues/494
# https://github.com/freedomofpress/dangerzone/issues/498 # https://github.com/freedomofpress/dangerzone/issues/498
if libreoffice_ext == "h2orestart.oxt" and platform.machine() in (
"arm64",
"aarch64",
):
raise ValueError(
"HWP / HWPX formats are not supported in ARM architectures"
)
if libreoffice_ext == "h2orestart.oxt" and running_on_qubes(): if libreoffice_ext == "h2orestart.oxt" and running_on_qubes():
raise errors.DocFormatUnsupportedHWPQubes() raise errors.DocFormatUnsupportedHWPQubes()
if libreoffice_ext: if libreoffice_ext:

View file

@ -553,15 +553,13 @@ class DocSelectionWidget(QtWidgets.QWidget):
self.file_dialog.setWindowTitle("Open Documents") self.file_dialog.setWindowTitle("Open Documents")
self.file_dialog.setFileMode(QtWidgets.QFileDialog.ExistingFiles) self.file_dialog.setFileMode(QtWidgets.QFileDialog.ExistingFiles)
# XXX: We disable loading HWP/HWPX files on Qubes or MacOS M1 platforms, because # XXX: We disable loading HWP/HWPX files on Qubes, because H2ORestart does not work there.
# H2ORestart does not work there. See: # See:
# #
# https://github.com/freedomofpress/dangerzone/issues/494 # https://github.com/freedomofpress/dangerzone/issues/494
# https://github.com/freedomofpress/dangerzone/issues/498
hwp_filters = "*.hwp *.hwpx" hwp_filters = "*.hwp *.hwpx"
if platform.machine() in ("arm64", "aarch64") or is_qubes_native_conversion(): if is_qubes_native_conversion():
hwp_filters = "" hwp_filters = ""
self.file_dialog.setNameFilters( 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} *.jpg *.jpeg *.gif *.png *.tif *.tiff)"

View file

@ -4,7 +4,6 @@ import base64
import contextlib import contextlib
import copy import copy
import os import os
import platform
import re import re
import shutil import shutil
import sys import sys
@ -308,7 +307,7 @@ class TestCliConversion(TestCliBasic):
class TestExtraFormats(TestCli): class TestExtraFormats(TestCli):
@for_each_external_doc("*hwp*") @for_each_external_doc("*hwp*")
def test_hancom_office(self, doc: str) -> None: def test_hancom_office(self, doc: str) -> None:
if platform.machine() in ("arm64", "aarch64") or is_qubes_native_conversion(): if is_qubes_native_conversion():
pytest.skip("HWP / HWPX formats are not supported on this platform") pytest.skip("HWP / HWPX formats are not supported on this platform")
with tempfile.NamedTemporaryFile("wb", delete=False) as decoded_doc: with tempfile.NamedTemporaryFile("wb", delete=False) as decoded_doc:
with open(doc, "rb") as encoded_doc: with open(doc, "rb") as encoded_doc: