Skip to content

Commit

Permalink
FIXUP: remove string headcut, rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
almet committed Jan 14, 2025
1 parent f6a616f commit f76ec36
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions dangerzone/isolation_provider/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

log = logging.getLogger(__name__)

MAX_CONVERSION_LOG_CHARS = 150 * 50 # up to ~150 lines of 50 characters
DOC_TO_PIXELS_LOG_START = "----- DOC TO PIXELS LOG START -----"
DOC_TO_PIXELS_LOG_END = "----- DOC TO PIXELS LOG END -----"

Expand Down Expand Up @@ -77,7 +76,7 @@ def read_int(f: IO[bytes]) -> int:
return int.from_bytes(untrusted_int, "big", signed=False)


def read_debug_text(text: bytes) -> str:
def sanitize_debug_text(text: bytes) -> str:
"""Read all the buffer and return a sanitized version"""
untrusted_text = text.decode("ascii", errors="replace")
return replace_control_chars(untrusted_text, keep_newlines=True)
Expand Down Expand Up @@ -358,7 +357,7 @@ def doc_to_pixels_proc(
stderr_thread.join(timeout=1)

debug_bytes = stderr.getvalue()
debug_log = read_debug_text(debug_bytes)[:MAX_CONVERSION_LOG_CHARS]
debug_log = sanitize_debug_text(debug_bytes)

incomplete = "(incomplete)\n" if stderr_thread.is_alive() else ""

Expand Down

0 comments on commit f76ec36

Please sign in to comment.