Skip to content

Commit

Permalink
Enable HWP conversion on MacOS M1
Browse files Browse the repository at this point in the history
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 M1 systems (#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.

Fixes #498

[1]: https://gitlab.alpinelinux.org/alpine/aports/-/commit/74d443f479df15fc57e6fde6ac02a36b24afdded
  • Loading branch information
OctopusET authored and apyrgio committed Sep 6, 2023
1 parent acd615e commit 214ce97
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ Dangerzone can convert these types of document into safe PDFs:
- ODF Graphics (`.odg`)
- Hancom HWP (Hangul Word Processor) (`.hwp`, `.hwpx`)
* Not supported on
[MacOS with Apple Silicon CPU](https://github.com/freedomofpress/dangerzone/issues/498)
or [Qubes OS](https://github.com/freedomofpress/dangerzone/issues/494)
[Qubes OS](https://github.com/freedomofpress/dangerzone/issues/494)
- Jpeg (`.jpg`, `.jpeg`)
- GIF (`.gif`)
- PNG (`.png`)
Expand Down
8 changes: 0 additions & 8 deletions dangerzone/conversion/doc_to_pixels.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import asyncio
import glob
import os
import platform
import re
import shutil
import sys
Expand Down Expand Up @@ -167,13 +166,6 @@ async def convert(self) -> None:
#
# https://github.com/freedomofpress/dangerzone/issues/494
# 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():
raise ValueError("HWP / HWPX formats are not supported in Qubes")
if libreoffice_ext:
Expand Down
8 changes: 3 additions & 5 deletions dangerzone/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,13 @@ def __init__(self, dangerzone: DangerzoneGui) -> None:
self.file_dialog.setWindowTitle("Open Documents")
self.file_dialog.setFileMode(QtWidgets.QFileDialog.ExistingFiles)

# XXX: We disable loading HWP/HWPX files on Qubes or MacOS M1 platforms, because
# H2ORestart does not work there. See:
# XXX: We disable loading HWP/HWPX files on Qubes, because H2ORestart does not work there.
# See:
#
# https://github.com/freedomofpress/dangerzone/issues/494
# https://github.com/freedomofpress/dangerzone/issues/498
hwp_filters = "*.hwp *.hwpx"
if platform.machine() in ("arm64", "aarch64") or is_qubes_native_conversion():
if is_qubes_native_conversion():
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)"
Expand Down
3 changes: 1 addition & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import contextlib
import copy
import os
import platform
import re
import shutil
import sys
Expand Down Expand Up @@ -308,7 +307,7 @@ def test_dummy_conversion_bulk(self, tmp_path: Path, sample_pdf: str) -> None:
class TestExtraFormats(TestCli):
@for_each_external_doc("*hwp*")
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")
with tempfile.NamedTemporaryFile("wb", delete=False) as decoded_doc:
with open(doc, "rb") as encoded_doc:
Expand Down

0 comments on commit 214ce97

Please sign in to comment.