Skip to content

Escape markup in TextPrompt default value - #2234

Open
davide-pi wants to merge 1 commit into
spectreconsole:mainfrom
davide-pi:fix/1181-escape-default-value
Open

davide-pi wants to merge 1 commit into
spectreconsole:mainfrom
davide-pi:fix/1181-escape-default-value

Conversation

@davide-pi

@davide-pi davide-pi commented Oct 14, 2026 •

Copy link
Copy Markdown

Fixes #1181

  • I have read the Contribution Guidelines
  • I have checked that there isn't already another pull request that solves the above issue
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors

AI disclosure: Claude Code was used to investigate the issue and draft the fix and test; changes were reviewed and verified locally.

Changes

TextPrompt interpolated the default value into the prompt markup without escaping it, so values containing brackets (e.g. root['config'][0]) threw an InvalidOperationException. The default value, masked or not, is now escaped before being written.

Added a test covering a default value with brackets.

Note: AnsiConsoleTests+Size.Should_Not_Throw_When_Live_Display_Overflows_And_Output_Reports_Negative_Height fails on main as well, independently of this change.

@davide-pi

Copy link
Copy Markdown
Author

The Build failure is unrelated to this change: NuGet audit errors on SixLabors.ImageSharp 3.1.12 currently break every PR build. Details in #2235.

@patriksvensson

Copy link
Copy Markdown
Contributor

@davide-pi Yeah, I will need to solve this asap. We probably need to move the imagesharp addin to a separate repository and update to version 4 due to how licensing works.

This branch has not been deployed

No deployments
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.

Exception when calling TextPrompt.DefaultValue(value) with brackets

2 participants