Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] text_markdown_urled breaks links that contain '_' #1654

Closed
moonbaseDelta opened this issue Nov 28, 2019 · 2 comments
Closed

[BUG] text_markdown_urled breaks links that contain '_' #1654

moonbaseDelta opened this issue Nov 28, 2019 · 2 comments
Labels
Milestone

Comments

@moonbaseDelta
Copy link

Seems that TG servers are escaping '_' in links by default, yet the library functions blindly replace it by '\ _'.

Try it out - 'https://site_name.com' becomes 'https: // site \ _name.com' after
msg.text_markdown_urled or
msg.caption_markdown_urled

Current tests miss exactly this case


Guess tomorrow I'll write and commit my solution, need this for work anyway. The simpliest one is to get final urled string and replace '_' by '_' inside the url clauses.

@moonbaseDelta moonbaseDelta changed the title text_markdown_urled breaks links that contain '_' [BUG] text_markdown_urled breaks links that contain '_' Nov 28, 2019
@moonbaseDelta
Copy link
Author

moonbaseDelta commented Nov 29, 2019

So, that worked fine for my task, hope it'll help somebody.

import re
...
...


def fix_missescapes(markdown_urled):
    return re.sub(r'\[(.*?)\]\((.*?)\)', lambda x: x.group(0).replace('\_', '_'), markdown_urled) 

...
bot.<send_anything>(caption = fix_missescapes(message.caption_markdown_urled), ...)
...

@Bibo-Joshi Bibo-Joshi added this to the 13.0 milestone Jan 19, 2020
@Bibo-Joshi
Copy link
Member

Hi. Sorry for the late reply. This should be fixed by #1508 (see this line)
I will add a test case for this.

@Bibo-Joshi Bibo-Joshi mentioned this issue Feb 17, 2020
10 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Aug 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants