microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.28k stars 675 forks source link

RichEditBox: setting Link property to a zero width space range crashes the app #3572

Open FrayxRulez opened 3 years ago

FrayxRulez commented 3 years ago

Describe the bug I have a chat application where I use a RichEditBox to compose messages. Once sent, messages including a link will generate a preview for the webpage, hence it is a common practice for users to use a zero width character as the display text for the link, to get the preview without the url being visible in the message itself. Now the problem is: if I try to set Link property to a ITextRange containing only a ZERO WIDTH SPACE (0x200B) the app will crash due to a catastrophic failure.

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'

Expected behavior

Screenshots

Version Info

NuGet package version:

Windows app type: UWP Win32
Windows 10 version Saw the problem?
Insider Build (xxxxx)
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop
Xbox
Surface Hub
IoT

Additional context

FrayxRulez commented 3 years ago

Same applies to a wide variety of character, including space.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

tipa commented 1 year ago

Still crashing

FrayxRulez commented 1 year ago

Here’s the list of all the characters that cause a crash:

private static readonly char[] _unsafeChars = new[]
{
    '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', '\u0008',
    '\u0009', '\u000a', '\u000b', '\u000c', '\u000d', '\u000e', '\u000f', '\u0010', '\u0011',
    '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', '\u0018', '\u0019', '\u001a',
    '\u001b', '\u001c', '\u001d', '\u001e', '\u001f', '\u0020', '\u007f', '\u0080', '\u0081',
    '\u0082', '\u0083', '\u0084', '\u0085', '\u0086', '\u0087', '\u0088', '\u0089', '\u008a',
    '\u008b', '\u008c', '\u008d', '\u008e', '\u008f', '\u0090', '\u0091', '\u0092', '\u0093',
    '\u0094', '\u0095', '\u0096', '\u0097', '\u0098', '\u0099', '\u009a', '\u009b', '\u009c',
    '\u009d', '\u009e', '\u009f', '\u00a0', '\u0600', '\u0601', '\u0602', '\u0603', '\u06dd',
    '\u070f', '\u1680', '\u17b4', '\u17b5', '\u180e', '\u2000', '\u2001', '\u2002', '\u2003',
    '\u2004', '\u2005', '\u2006', '\u2007', '\u2008', '\u2009', '\u200a', '\u200b', '\u200c',
    '\u200d', '\u200e', '\u200f', '\u2028', '\u2029', '\u202a', '\u202b', '\u202c', '\u202d',
    '\u202e', '\u202f', '\u205f', '\u2060', '\u2061', '\u2062', '\u2063', '\u2064', '\u206a',
    '\u206b', '\u206c', '\u206d', '\u206e', '\u206f', '\u3000', '\ufdd0', '\ufdd1', '\ufdd2',
    '\ufdd3', '\ufdd4', '\ufdd5', '\ufdd6', '\ufdd7', '\ufdd8', '\ufdd9', '\ufdda', '\ufddb',
    '\ufddc', '\ufddd', '\ufdde', '\ufddf', '\ufde0', '\ufde1', '\ufde2', '\ufde3', '\ufde4',
    '\ufde5', '\ufde6', '\ufde7', '\ufde8', '\ufde9', '\ufdea', '\ufdeb', '\ufdec', '\ufded',
    '\ufdee', '\ufdef', '\ufeff', '\ufff9', '\ufffa', '\ufffb', '\ufffc', '\ufffe'
 };