Skip to content

Conversation

TomJGooding
Copy link
Collaborator

Fix the markup parsing of invalid closing tags missing the closing square bracket.

Currently [/ is interpreted as an auto-closing tag, which will crash with a MarkupError if there's nothing to close.

Fixes #6155

Please review the following checklist.

  • Docstrings on all new or modified functions / classes
  • Updated documentation
  • Updated CHANGELOG.md (where appropriate)

Fix the markup parsing of invalid closing tags missing the closing
square bracket.

Currently `[/` is interpreted as an auto-closing tag, which will crash
with a `MarkupError` if there's nothing to close.

Fixes Textualize#6155
@TomJGooding
Copy link
Collaborator Author

TomJGooding commented Oct 5, 2025

This handles the unexpected EOF when parsing "open_closing_tag". I wasn't sure if we want to handle other invalid tags similar to the "open_tag" parsing?

elif token_name == "open_tag":
tag_text = []
eof = False
contains_text = False
for token in iter_tokens:
if token.name == "end_tag":
break
elif token.name == "text":
contains_text = True
elif token.name == "eof":
eof = True
tag_text.append(token.value)
if contains_text or eof:
# "tag" was unparsable

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.

Invalid tag crashes app even when escaping

1 participant