From 17bed1a724fb498c4184c83f35e93d6510e8fd6f Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Thu, 19 Sep 2024 14:29:51 +0300 Subject: [PATCH] FIXUP: Moar CI fixes --- dangerzone/document.py | 4 ++++ dangerzone/isolation_provider/base.py | 5 ++++- poetry.lock | 2 +- pyproject.toml | 2 +- tests/isolation_provider/test_qubes.py | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dangerzone/document.py b/dangerzone/document.py index 0b3e3f4..5fc1eda 100644 --- a/dangerzone/document.py +++ b/dangerzone/document.py @@ -123,6 +123,10 @@ class Document: self.validate_output_filename(filename) self._output_filename = filename + @property + def sanitized_output_filename(self) -> None: + return util.replace_control_chars(self.output_filename) + @property def suffix(self) -> str: return self._suffix diff --git a/dangerzone/isolation_provider/base.py b/dangerzone/isolation_provider/base.py index 261962a..e0c0f66 100644 --- a/dangerzone/isolation_provider/base.py +++ b/dangerzone/isolation_provider/base.py @@ -216,7 +216,10 @@ class IsolationProvider(ABC): # Ensure nothing else is read after all bitmaps are obtained p.stdout.close() - safe_doc.save(document.output_filename) + # Saving it with a different name first, because PyMuPDF cannot handle + # non-Unicode chars. + safe_doc.save(document.sanitized_output_filename) + os.replace(document.sanitized_output_filename, document.output_filename) # TODO handle leftover code input text = "Converted document" diff --git a/poetry.lock b/poetry.lock index 25f1ee9..ec22a9a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1046,4 +1046,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<3.13" -content-hash = "93097a7d09c23ca12dbedd440965381fdd12dca2a8b1a0defe0f75b0e4e2092a" +content-hash = "9b4083a41b94d03d7688fb6fcc82a0af9839f4dfc769204548c44bf35bcda60b" diff --git a/pyproject.toml b/pyproject.toml index dad5bf0..d050f10 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ python = ">=3.9,<3.13" click = "*" appdirs = "*" PySide6 = "^6.7.1" -PyMuPDF = "^1.23.8" +PyMuPDF = "^1.23.3" # The version in Fedora 39 colorama = "*" pyxdg = {version = "*", platform = "linux"} requests = "*" diff --git a/tests/isolation_provider/test_qubes.py b/tests/isolation_provider/test_qubes.py index 77ea939..acd1fbf 100644 --- a/tests/isolation_provider/test_qubes.py +++ b/tests/isolation_provider/test_qubes.py @@ -79,7 +79,7 @@ class TestQubes(IsolationProviderTest): ) with pytest.raises(errors.ConverterProcException): doc = Document(sample_doc) - provider.doc_to_pixels(doc, tmpdir, proc) + provider._convert(doc, tmpdir, None, proc) assert provider.get_proc_exception(proc) == errors.QubesQrexecFailed