Loading, saving and loading RTF leads to exception
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
### Description
Loading some RTF in a `RichTextBox`, saving it and loading it again causes an exception to be thrown.
This happens because the RTF contains a hyperlink which contains an umlaut ("ö" in this example).
That umlaut is correctly escaped in the source RTF with "\'f6".
Loading the source RTF works fine.
Saving the RTF with `RichTextBox` causes the correctly escaped text to become `'f6`.
Loading this again causes an exception while trying to construct the NavigationUri, as an unescaped "'" is not valid in an URI.
After some investigation the issue seems to be that:
XamlToRtfWriter.WriteInlineChild calls BamlResourceContentUtil.UnescapeString which then simply removes the "\\" before the "'", thus producing an invalid URI.
One way to solve this would be to add
```
else if (documentNode.NavigateUri[i] == "'")
{
_rtfBuilder.Append("\\'");
}
```
### Reproduction Steps
See attached repro project.
[UmlautIssue.zip](https://github.com/dotnet/wpf/files/10918031/UmlautIssue.zip)
### Expected behavior
No exception should occur and RTF should be rendered.
### Actual behavior
Exception is thrown during load (after save from `RichTextBox`).
### Regression?
_No response_
### Known Workarounds
_No response_
### Impact
_No response_
### Configuration
Tested with .NET 4.8 and .NET 6.0.
### Other information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.