Skip to content

Allow nested brackets in markup.escape tag matching#6650

Open
Devil1716 wants to merge 1 commit into
Textualize:mainfrom
Devil1716:fix/markup-escape-nested-brackets
Open

Allow nested brackets in markup.escape tag matching#6650
Devil1716 wants to merge 1 commit into
Textualize:mainfrom
Devil1716:fix/markup-escape-nested-brackets

Conversation

@Devil1716

Copy link
Copy Markdown

Summary

  • Change markup.escape tag regex from [^[] to [^\]] so outer tags containing nested [ are escaped.
  • Add a regression test for Pydantic-style nested-bracket strings.

Test plan

  • pytest tests/test_markup.py::test_escape_nested_brackets
  • pytest tests/test_markup.py

Fixes #6614

The previous character class [^[] rejected any tag-like segment that
contained a nested '[', so strings like Pydantic error messages were
left unescaped and later raised MarkupError in to_content. Match until
the closing ']' instead.

Fixes Textualize#6614

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

markup.escape() doesn't escape an outer tag when it contains a nested "["

1 participant