Skip to content

Commit

Permalink
[cuegui] Decode logs on LogViewPlugin (#1464)
Browse files Browse the repository at this point in the history
Logs should be decoded using utf-8 ignoring chars that are not valid. If
the decoding process fails, the original content will be displayed

Co-authored-by: akim-ruslanov <[email protected]>
  • Loading branch information
DiegoTavares and akim-ruslanov authored Aug 15, 2024
1 parent 7211e49 commit 708030c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cuegui/cuegui/plugins/LogViewPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,14 @@ def _update_log_content(self, content, log_mtime):
self._content_box.setPlainText(content)
else:
current_text = (self._content_box.toPlainText() or '')

# ignore decoding higher order bytes outside ordinal range(128)
# ex: umlats, latin-1 etc.
try:
content = content.decode("utf-8", errors="ignore")
current_text = current_text.decode("utf-8", errors="ignore")
except AttributeError:
pass
new_text = content.lstrip(str(current_text))
if new_text:
self._content_box.appendPlainText(new_text)
Expand Down

0 comments on commit 708030c

Please sign in to comment.