Fix Rich markup issues with square brackets in user content#137
Merged
Fix Rich markup issues with square brackets in user content#137
Conversation
Fixes #135: MarkupError crash on [/path] patterns Fixes #136: Silent stripping of [bug] tags from titles Uses rich.markup.escape() to escape user-provided content while keeping Rich markup enabled for intentional formatting (hyperlinks, bold labels, etc.). Changes: - Import markup.escape from rich library - Add _escape() helper method to safely escape user content - Escape all user content in _display_task_yaml() (15 locations): * Task fields (Name, Description, etc.) * Board/Column names * History transitions * Comments * Metadata values - Escape all user content in _display_task_tree() (15 locations): * Task fields * Board/Column names * History transitions * Comments * Metadata values - Preserve Text objects (hyperlinks) without escaping - Combine YAML quote escaping with Rich markup escaping where needed Testing: - T525 now displays without crashing (had [/path] patterns) - T2163 now shows full title with [bug] prefix (was being stripped) - Search results display correctly - --format=strict still works as expected 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Timpan4
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two related issues where Rich library incorrectly interprets square brackets in user-provided content as markup syntax:
[/path]patterns[bug]tags from task titlesProblem
Rich library treats square brackets
[...]as markup syntax for styling/formatting. When user content contains literal square brackets:[/text]→ Interpreted as closing tag → Crashes withMarkupError[word]→ Interpreted as invalid tag → Silently removed from displayExample Issues
T525 - Contains file path
[/source/kubespray/...]:T2163 - Title has
[bug]prefix:Solution
Use
rich.markup.escape()to escape all user-provided content while keeping Rich markup enabled for intentional formatting (hyperlinks, bold labels, etc.).Implementation
Import
markup.escapefrom RichAdd helper method
_escape()to safely escape content:NoneTextobjects (already safe Rich objects like hyperlinks)escape(str(content))Escape user content in 30 locations across 2 display methods:
_display_task_yaml()method (15 locations):_display_task_tree()method (15 locations):Preserve intentional formatting:
self.format_link()returnTextobjects_escape()checksisinstance(content, Text)and doesn't escape themHandle combined escaping:
'') and Rich markup escapingTesting
Files Changed
phabfive/maniphest.py: +55 insertions, -27 deletionsescapefromrich.markup_escape()helper method (26 lines)Impact
Fixes:
[/path]patterns (Rich MarkupError when task description contains square brackets #135)[bug],[feature],[urgent]tags (Rich format silently strips square bracket tags from task titles #136)Preserves:
--format=strictunaffected (uses different code path)Related Issues
Closes #135
Closes #136
🤖 Generated with Claude Code