fix(ui): escape ClassName/process name in list-windows to prevent Spectre markup errors#479
Merged
Merged
Conversation
Spectre.Console MarkupLine treats unescaped square brackets in interpolated values as markup tags. When a window's class name contains brackets (e.g. CLR/DCOM-hosted windows that report a class name like '[DefaultDomain;;<guid>]'), the markup parser tries to resolve the inner brackets as a color/style and throws: Could not find color or style 'DefaultDomain;;<guid>'. The line ended after a successful run of windows, so the user saw all windows printed and then a stray error at the end (the failure happened on the next iteration before any further output). The outer '[[ ]]' around ClassName only escapes the wrapper brackets — characters inside the value pass through unescaped. Fix: Markup.Escape ClassName, Label, and process name before interpolation. Title was already escaped. Fixes #469 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash in the human-readable output path of winapp ui list-windows caused by unescaped Spectre.Console markup characters in window metadata (notably bracketed class names), resolving issue #469.
Changes:
- Escape process name, window label, and class name with
Spectre.Console.Markup.Escapebefore interpolating intoMarkupLine. - Preserve existing behavior for JSON output (unchanged).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Build Metrics ReportBinary Sizes
Test Results✅ 764 passed out of 764 tests in 416.5s (-41.3s vs. baseline) Test Coverage❌ 20.8% line coverage, 35.1% branch coverage · ✅ no change vs. baseline CLI Startup Time38ms median (x64, Updated 2026-04-20 21:48:33 UTC · commit |
zateutsch
approved these changes
Apr 21, 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.
Fixes #469
Root cause
winapp ui list-windowsprints each window via Spectre.ConsoleMarkupLine. The format string interpolatesinfo.ClassName(andprocName,info.Label) without escaping.info.ClassNameis wrapped in[[ ]]which only escapes the outer brackets — any brackets inside the value pass through as raw markup.When
GetClassNamereturns a name containing brackets (e.g. CLR/DCOM-hosted windows that report[DefaultDomain;;<guid>]), Spectre parses[DefaultDomain;;<guid>]as a style/color tag and throws:Because the throw happens on the next iteration after a long string of successful prints, the user sees all windows listed followed by a stray error — exactly what the screenshot shows.
This isn't always reproducible: it only fires when at least one currently-open window has a bracketed class name, which depends on what's running on the box.
Fix
Markup.EscapeClassName,Label, and the process name before interpolation. Title was already escaped.Verification
dotnet buildcleanwinapp ui list-windowsruns cleanly on my box (exit 0, no error trailer)