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:
deeplow 2023-06-23 08:35:59 +01:00
parent 9f1abe2836
commit f41cefde1d
No known key found for this signature in database
GPG key ID: 577982871529A52A
3 changed files with 10 additions and 2 deletions

View file

@ -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:

View file

@ -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:

View file

@ -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)