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

Telegram: Do not apply any markup to URL entities #1808

Merged
merged 1 commit into from Apr 21, 2022

Conversation

ValdikSS
Copy link
Contributor

handleEntities code uses simple modification offset which does not
allow to detect whether the offset is placed before or after
the element in already modified string.
This works fine is most cases as Telegram server always sort the
elements by offset, in ascending order.
However, this is not the case when the modification, for example bold
text, is applied to the URL. In this case, the offset of URL and
bold entity is equal, which raises the issue.

This commit introduces additional hack for this case, stripping
any entities which intersect with URL.

bridge/telegram/handlers.go Outdated Show resolved Hide resolved
@42wim 42wim added the telegram label Apr 21, 2022
@42wim 42wim added this to the 1.25.1 milestone Apr 21, 2022
handleEntities code uses simple modification offset which does not
allow to detect whether the offset is placed before or after
the element in already modified string.
This works fine is most cases as Telegram server always sort the
elements by offset, in ascending order.
However, this is not the case when the modification, for example bold
text, is applied to the URL. In this case, the offset of URL and
bold entity is equal, which raises the issue.

This commit introduces additional hack for this case, stripping
any entities which intersect with URL.
@codeclimate
Copy link

codeclimate bot commented Apr 21, 2022

Code Climate has analyzed commit 21e8718 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2

View more on Code Climate.

@ValdikSS
Copy link
Contributor Author

Complexity did not decrease :D

@42wim
Copy link
Owner

42wim commented Apr 21, 2022

But linter is happy, and we have 1 nested if less :)

@42wim 42wim merged commit ce18c94 into 42wim:master Apr 21, 2022
@42wim
Copy link
Owner

42wim commented Apr 21, 2022

Thank you @ValdikSS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants