mirror of
https://github.com/github/spec-kit.git
synced 2026-08-03 06:26:30 +08:00
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:
@@ -10077,6 +10077,60 @@ steps:
|
||||
assert "desc [with] brackets" in result.output
|
||||
assert "tag[1]" in result.output
|
||||
|
||||
def test_catalog_list_escapes_rich_markup(self, project_dir, 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.workflows.catalog import WorkflowCatalog
|
||||
|
||||
monkeypatch.chdir(project_dir)
|
||||
configs = [
|
||||
{
|
||||
"name": "Bracket [Catalog]",
|
||||
"url": "https://example.com/[cat].json",
|
||||
"description": "desc [with] brackets",
|
||||
"install_allowed": True,
|
||||
},
|
||||
]
|
||||
monkeypatch.setattr(
|
||||
WorkflowCatalog,
|
||||
"get_catalog_configs",
|
||||
lambda self: [dict(c) for c in configs],
|
||||
)
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(app, ["workflow", "catalog", "list"])
|
||||
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
|
||||
|
||||
def test_step_catalog_list_escapes_rich_markup(self, project_dir, monkeypatch):
|
||||
"""User-editable step-catalog name/url/description must not be parsed as Rich markup."""
|
||||
from typer.testing import CliRunner
|
||||
from specify_cli import app
|
||||
from specify_cli.workflows.catalog import StepCatalog
|
||||
|
||||
monkeypatch.chdir(project_dir)
|
||||
configs = [
|
||||
{
|
||||
"name": "Bracket [Step]",
|
||||
"url": "https://example.com/[step].json",
|
||||
"description": "step [with] brackets",
|
||||
"install_allowed": True,
|
||||
},
|
||||
]
|
||||
monkeypatch.setattr(
|
||||
StepCatalog,
|
||||
"get_catalog_configs",
|
||||
lambda self: [dict(c) for c in configs],
|
||||
)
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(app, ["workflow", "step", "catalog", "list"])
|
||||
assert result.exit_code == 0, result.output
|
||||
assert "Bracket [Step]" in result.output
|
||||
assert "https://example.com/[step].json" in result.output
|
||||
assert "step [with] brackets" in result.output
|
||||
|
||||
# -- update ----------------------------------------------------------
|
||||
|
||||
def test_update_no_workflows_installed(self, project_dir, monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user