fix: escape Rich markup in catalog list output (#3738)

The `catalog list` subcommands for workflows, workflow steps, presets,
and integrations printed user-editable catalog fields (name/url/
description from the `*-catalogs.yml` files) through `console.print`
with Rich markup enabled. Any bracketed content such as a description
`Does [stuff] nicely` was parsed as a style tag and silently swallowed,
and a malformed tag could raise while rendering.

Route each untrusted field through the module's already-imported
`escape` helper, matching the pattern already used by
`extension catalog list`.

Adds regression tests for all four commands that inject bracketed
name/url/description and assert the brackets survive verbatim in the
output.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Noor ul ain
2026-07-27 20:15:37 +05:00
committed by GitHub
parent 103ad73775
commit 99dc915ae3
6 changed files with 124 additions and 13 deletions

View File

@@ -633,6 +633,40 @@ class TestIntegrationListCatalog:
assert "copilot" in result.output
assert "installed" in result.output
def test_catalog_list_escapes_rich_markup(self, tmp_path, monkeypatch):
"""User-editable catalog name/url/description must not be parsed as Rich markup."""
from typer.testing import CliRunner
from specify_cli import app
from specify_cli.integrations.catalog import IntegrationCatalog
runner = CliRunner()
project = self._init_project(tmp_path)
configs = [
{
"name": "Bracket [Catalog]",
"url": "https://example.com/[cat].json",
"description": "desc [with] brackets",
"install_allowed": True,
},
]
monkeypatch.setattr(
IntegrationCatalog,
"get_project_catalog_configs",
lambda self: [dict(c) for c in configs],
)
old = os.getcwd()
try:
os.chdir(project)
result = runner.invoke(app, ["integration", "catalog", "list"])
finally:
os.chdir(old)
assert result.exit_code == 0, result.output
assert "Bracket [Catalog]" in result.output
assert "https://example.com/[cat].json" in result.output
assert "desc [with] brackets" in result.output
# ---------------------------------------------------------------------------
# CLI: integration upgrade