The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
Bug report (I searched for similar issues and did not find one)
Current behavior
The MarkdownTextBlock throws an ArgumentOutOfRange exception when entering this string:
r/Steam: www.
NOTE: the issue is present even if the address is just "ww.", or with full URLs. Eg. "www.google.com" crashes as well, if the string starts with that "r/Steam: " prefix.
In particular, with the string mentioned in the title, it happens because the end parameter is 7, while the start parameter is 2, so the resulting length is negative.
Expected behavior
The markdown should be parsed correctly as usual.
Minimal reproduction of the problem with instructions
I'm submitting a...
Current behavior
The
MarkdownTextBlock
throws anArgumentOutOfRange
exception when entering this string:NOTE: the issue is present even if the address is just "ww.", or with full URLs. Eg. "www.google.com" crashes as well, if the string starts with that "r/Steam: " prefix.
The crash happens exactly here: https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/3b5a1f480d65c649a1732a8b8a11866ed3c08836/Microsoft.Toolkit.Parsers/Markdown/Inlines/TextRunInline.cs#L384
In particular, with the string mentioned in the title, it happens because the
end
parameter is 7, while thestart
parameter is 2, so the resulting length is negative.Expected behavior
The markdown should be parsed correctly as usual.
Minimal reproduction of the problem with instructions
TextBox
Environment