Desktop: Resolves #11600: OneNote imported notes have broken links when there are chineses characters on link #11602
+367
−26
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.
Should be merged after #11598
Resolves #11600
Summary
Links from notes imported from OneNote sometimes would break and not find the final delimiter when being rendered to HTML, but I could never understand why that happens, I think this is the reason:
First how the renderer for the rich text works, it has 3 parts:
Example
In the current implementation wasn't implemented like this, it was assumed that the index-to-styles would always match, meaning that content that should be rendered as (ignore line breaks, included to help reading):
Would be rendered as
It is not entirely clear to me why that happens, but looking at the example above it is possible to see that a different charset is used for the two Chinese characters (index 83 and 85).
I don't know why that would be necessary, but this solution should fix the issue.
Testing
I added an automated test case that this PR is based on