mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 09:52:37 +02:00
Add "armor" around conversion log
Add GPG-styled "armor" around conversion logs -----CONVERSION LOG START----- Creator: Writer Producer: LibreOffice 6.4 [...] -----CONVERSION LOG END-----
This commit is contained in:
parent
9f1abe2836
commit
f41cefde1d
3 changed files with 10 additions and 2 deletions
|
@ -84,6 +84,14 @@ class IsolationProvider(ABC):
|
||||||
def get_max_parallel_conversions(self) -> int:
|
def get_max_parallel_conversions(self) -> int:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def sanitize_conversion_str(self, untrusted_conversion_str: str) -> str:
|
||||||
|
conversion_string = replace_control_chars(untrusted_conversion_str)
|
||||||
|
|
||||||
|
# Add armor (gpg-style)
|
||||||
|
armor_start = "-----CONVERSION LOG START-----\n"
|
||||||
|
armor_end = "-----CONVERSION LOG END-----"
|
||||||
|
return armor_start + conversion_string + armor_end
|
||||||
|
|
||||||
|
|
||||||
# From global_common:
|
# From global_common:
|
||||||
|
|
||||||
|
|
|
@ -295,7 +295,7 @@ class Container(IsolationProvider):
|
||||||
with open(log_path, "r", encoding="ascii", errors="replace") as f:
|
with open(log_path, "r", encoding="ascii", errors="replace") as f:
|
||||||
untrusted_log = f.read(MAX_CONVERSION_LOG_CHARS)
|
untrusted_log = f.read(MAX_CONVERSION_LOG_CHARS)
|
||||||
log.info(
|
log.info(
|
||||||
f"Conversion output (doc to pixels):\n{replace_control_chars(untrusted_log)}"
|
f"Conversion output (doc to pixels):\n{self.sanitize_conversion_str(untrusted_log)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
|
|
|
@ -145,7 +145,7 @@ class Qubes(IsolationProvider):
|
||||||
if getattr(sys, "dangerzone_dev", False):
|
if getattr(sys, "dangerzone_dev", False):
|
||||||
untrusted_log = read_debug_text(p)
|
untrusted_log = read_debug_text(p)
|
||||||
log.info(
|
log.info(
|
||||||
f"Conversion output (doc to pixels):\n{replace_control_chars(untrusted_log)}"
|
f"Conversion output (doc to pixels)\n{self.sanitize_conversion_str(untrusted_log)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# FIXME pass OCR stuff properly (see #455)
|
# FIXME pass OCR stuff properly (see #455)
|
||||||
|
|
Loading…
Reference in a new issue