Fix: overly escape and offset error for markdown v2 and HTML symbols when nested#2312
Merged
Bibo-Joshi merged 2 commits intopython-telegram-bot:masterfrom Jan 12, 2021
Merged
Conversation
Signed-off-by: Eana Hufwe <ilove@1a23.com>
Member
|
Hi, thanks for the finding and the PR! On a closer look, the same problem happens with HTML formatting (replace |
Signed-off-by: Eana Hufwe <ilove@1a23.com>
Contributor
Author
|
@Bibo-Joshi, nice spot! I just added the same fix to the HTML parser as well. For the tests, I included the |
Member
|
Perfect, thanks for the contribution :) |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Previously, PTB is producing incorrect results when formatting a message into the Markdown v2 format (
Message.(text|caption)_markdown_v2). Specifically, when there is any of the need-to-escape characters_*~`>#+-=|{}.!appear in a nested entities, the last few characters was repeated at the end of the range.For example
<b><hashtag>#boldhashtag</hashtag></b>*#boldhashtag*g*#boldhashtag*<b><i>a{b+c}d</i></b>*_a\{b\+c\}d_\\}d**_a\{b\+c\}d_**
<hashtag />is used here just to represent the hashtag entity, Telegram does not support such a tag.The issue is suspected to be caused by the used of escaped text sequence for nested entities, which is causing a discrepancy in the length of text due to the introduction of
\.This PR fixes the issue by using the original text (
orig_text) as a basis for nested entity parsing. It also includes updated tests to address this issue.