From ba3c11dc9561b37ace115fbfd7bc42c5a778151e Mon Sep 17 00:00:00 2001 From: Jan Vetesnik Date: Sat, 13 Jun 2026 20:09:09 +0200 Subject: [PATCH] v0.2.2: escape log line text before feeding to Rich markup Synology logs often embed bracketed paths like `[/var/packages/SynoFinder/etc/etc-volume/collect.data]`. Rich interprets the leading `[/` as a closing tag, so RichLog crashed with MarkupError the first time the Logs tab was resized and the deferred-render queue was flushed. Wrap line.raw in rich.markup.escape() so brackets render as text. Co-Authored-By: Claude Opus 4.7 (1M context) --- dsmview/__init__.py | 2 +- dsmview/ui/tabs/logs.py | 6 +++++- pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dsmview/__init__.py b/dsmview/__init__.py index 3ced358..b5fdc75 100644 --- a/dsmview/__init__.py +++ b/dsmview/__init__.py @@ -1 +1 @@ -__version__ = "0.2.1" +__version__ = "0.2.2" diff --git a/dsmview/ui/tabs/logs.py b/dsmview/ui/tabs/logs.py index 42820c0..c189a1b 100644 --- a/dsmview/ui/tabs/logs.py +++ b/dsmview/ui/tabs/logs.py @@ -3,6 +3,7 @@ from __future__ import annotations from collections import deque from typing import Deque +from rich.markup import escape from textual.app import ComposeResult from textual.containers import Container from textual.widgets import RichLog, Static @@ -66,8 +67,11 @@ class LogsTab(Container): Severity.OTHER: theme.BORDER_TITLE, } color = color_for[line.severity] + # Raw log lines often contain literal brackets like + # `[/path/to/file]` which Rich's markup parser tries to interpret + # as closing tags. Escape so they render as text. src = f"[dim]{line.source:<8}[/]" - return f"{src} [{color}]{line.raw}[/]" + return f"{src} [{color}]{escape(line.raw)}[/]" def _rerender(self) -> None: self.log_view.clear() diff --git a/pyproject.toml b/pyproject.toml index d45f10e..26591ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "dsmview" -version = "0.2.1" +version = "0.2.2" description = "TUI SSH monitor for Synology DSM 7.x" readme = "README.md" license = { text = "MIT" }