You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fix is wrong and changes nothing. get_markdown_v3 is never called with invalid UTF-8. I have already identified actual cause of the mentioned issue and fixed it in the private TDLib version, which is supposed to be publicly available soon.
You are right; the invalid UTF-8 guard was the wrong fix. I force-pushed a corrected patch.
The issue I found is in get_markdown_v3: when closing a TextUrl, it added entity->argument.size() to utf16_added, but that argument can contain non-ASCII UTF-8. This can shift preserved entities after the link to invalid UTF-16 offsets in the generated Markdown before it is reparsed. The patch now uses text_length(entity->argument) and adds a regression with a Cyrillic URL followed by a custom emoji entity.
michaelsam94
changed the title
Handle invalid UTF-8 in Markdown formatting
Fix Markdown formatting offsets for non-ASCII URLs
Jul 6, 2026
The patch is correct now, but the same fix has already been done in the private TDLib version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Summary
Fixes #3686.
Tests