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

fix(message-parser): Link/URL parser issues #855

Merged
merged 5 commits into from
Oct 4, 2022

Conversation

hugocostadev
Copy link
Contributor

@hugocostadev hugocostadev commented Sep 28, 2022

TC-89 | TC-90 | TC-91 | TC-97

Proposed changes (including videos or screenshots)

This pull request fixes the following parsing problems:

  1. The link parser was not parsing Emphasis elements (bold, italic, and strike). - TC-91
    Current behavior:
    image
    Expected behavior
    image

  2. The link parser was not parsing some special chars - TC-90
    The following markdown input produces:

[Github link with hash](https://github.com/RocketChat/Rocket.Chat/pull/26751/files#diff-c87b108ecf1ede549f8ede68eca840fbb330180b927df0b8a0b4df5d06cbd89b)
https://github.com/RocketChat/Rocket.Chat/pull/26751/files#diff-c87b108ecf1ede549f8ede68eca840fbb330180b927df0b8a0b4df5d06cbd89b
<https://github.com/RocketChat/Rocket.Chat/pull/26751/files#diff-c87b108ecf1ede549f8ede68eca840fbb330180b927df0b8a0b4df5d06cbd89b|Github link with hash>

[Link with special chars](https://github.com/RocketChat/Rocket.Chat*[/]^_`{}~)
https://github.com/RocketChat/Rocket.Chat*[/]^_`{}~
<https://github.com/RocketChat/Rocket.Chat*[/]^_`{}~|Link with special chars>

[Google complex Link](https://www.google.com/url?rct=j&sa=t&url=https://ga.de/freizeit/region-erleben/bonn-und-region-tipps-fuers-wochenende-flohmarkt-rheinaue-weltkindertag-stadtfest_aid-53876987&ct=ga&cd=CAIyHDQ0NzEyYWE3MDA1MGNhNTQ6Y29tOmRlOkRFOlI&usg=AOvVaw3ySYrO9lM0iNSnk43gPVwZ)
https://www.google.com/url?rct=j&sa=t&url=https://ga.de/freizeit/region-erleben/bonn-und-region-tipps-fuers-wochenende-flohmarkt-rheinaue-weltkindertag-stadtfest_aid-53876987&ct=ga&cd=CAIyHDQ0NzEyYWE3MDA1MGNhNTQ6Y29tOmRlOkRFOlI&usg=AOvVaw3ySYrO9lM0iNSnk43gPVwZ
<https://www.google.com/url?rct=j&sa=t&url=https://ga.de/freizeit/region-erleben/bonn-und-region-tipps-fuers-wochenende-flohmarkt-rheinaue-weltkindertag-stadtfest_aid-53876987&ct=ga&cd=CAIyHDQ0NzEyYWE3MDA1MGNhNTQ6Y29tOmRlOkRFOlI&usg=AOvVaw3ySYrO9lM0iNSnk43gPVwZ|Google complex Link>

Current behavior:
image

Expected behavior
image

  1. Link/URL Wrong domains extensions highlighting - TC-89
    PS: It was removed invalid TLD that starts with a number, but still highlights possible URLs like (hugo.costa) because if we map all possible and valids TLDs (1.5k+) the parser durations would be huge and would impact the performance
    The following markdown input produces:
[9gag](https://9gag.com/)
[9gag](9gag.com)
<9gag.com|9gag>
9gag.com
[77.77%](77.77%)
77.77%
[77.77](77.77)
77.77
test.9gag

Current behavior:
image

Expected behavior
image

Issue(s)

RocketChat/Rocket.Chat#26889
RocketChat/Rocket.Chat#23020
RocketChat/Rocket.Chat#26815

Further comments

The fix number 1 address the changes made in Core repository PR: RocketChat/Rocket.Chat#26971 and needs to be tested together

Full markdown used for testing:

# Should parse

> [Jira TC-91](https://rocketchat.atlassian.net/jira/software/c/projects/TC/boards/36?modal=detail&selectedIssue=TC-91): [Messages rewirte] [issue] Link/URL not parsing Emphasis elements (bold, italic and strike)

[Test with *bold* element](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351)
[Test with _italic_ element](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351)
[Test with ~strike~ element](https://desk.rocket.chat/support/rocketchat/ShowHomePage.do#Cases/dv/413244000073043351)


> [Jira TC-90](https://rocketchat.atlassian.net/jira/software/c/projects/TC/boards/36?modal=detail&selectedIssue=TC-90): [Messages rewirte] [issue] Link/URL parsing with hash

[Github link with hash](https://github.com/RocketChat/Rocket.Chat/pull/26751/files#diff-c87b108ecf1ede549f8ede68eca840fbb330180b927df0b8a0b4df5d06cbd89b)
https://github.com/RocketChat/Rocket.Chat/pull/26751/files#diff-c87b108ecf1ede549f8ede68eca840fbb330180b927df0b8a0b4df5d06cbd89b
<https://github.com/RocketChat/Rocket.Chat/pull/26751/files#diff-c87b108ecf1ede549f8ede68eca840fbb330180b927df0b8a0b4df5d06cbd89b|Github link with hash>

[Link with special chars](https://github.com/RocketChat/Rocket.Chat*[/]^_`{}~)
https://github.com/RocketChat/Rocket.Chat*[/]^_`{}~
<https://github.com/RocketChat/Rocket.Chat*[/]^_`{}~|Link with special chars>

[Google complex Link](https://www.google.com/url?rct=j&sa=t&url=https://ga.de/freizeit/region-erleben/bonn-und-region-tipps-fuers-wochenende-flohmarkt-rheinaue-weltkindertag-stadtfest_aid-53876987&ct=ga&cd=CAIyHDQ0NzEyYWE3MDA1MGNhNTQ6Y29tOmRlOkRFOlI&usg=AOvVaw3ySYrO9lM0iNSnk43gPVwZ)
https://www.google.com/url?rct=j&sa=t&url=https://ga.de/freizeit/region-erleben/bonn-und-region-tipps-fuers-wochenende-flohmarkt-rheinaue-weltkindertag-stadtfest_aid-53876987&ct=ga&cd=CAIyHDQ0NzEyYWE3MDA1MGNhNTQ6Y29tOmRlOkRFOlI&usg=AOvVaw3ySYrO9lM0iNSnk43gPVwZ
<https://www.google.com/url?rct=j&sa=t&url=https://ga.de/freizeit/region-erleben/bonn-und-region-tipps-fuers-wochenende-flohmarkt-rheinaue-weltkindertag-stadtfest_aid-53876987&ct=ga&cd=CAIyHDQ0NzEyYWE3MDA1MGNhNTQ6Y29tOmRlOkRFOlI&usg=AOvVaw3ySYrO9lM0iNSnk43gPVwZ|Google complex Link>

> [Jira TC-89](https://rocketchat.atlassian.net/jira/software/c/projects/TC/boards/36?modal=detail&selectedIssue=TC-89): [Messages rewirte] [issue] Link/URL Wrong domains extensions highlighting

[9gag](https://9gag.com/)
[9gag](9gag.com)
<9gag.com|9gag>
9gag.com

# Should *NOT* parse

> [Jira TC-89](https://rocketchat.atlassian.net/jira/software/c/projects/TC/boards/36?modal=detail&selectedIssue=TC-89): [Messages rewirte] [issue] Link/URL Wrong domains extensions highlighting

[77.77%](77.77%)
77.77%
[77.77](77.77)
77.77
test.9gag

@guijun13 guijun13 merged commit d1d5337 into parser-issues Oct 4, 2022
@guijun13 guijun13 deleted the fix/link-url-parser branch October 4, 2022 14:31
gabriellsh added a commit that referenced this pull request Oct 5, 2022
* Add first test

* fix: check if is emoticon to preserver colon character

* fix(message-parser): Thumbs emoji becoming phone number (#858)

Co-authored-by: gabriellsh <[email protected]>

* fix(message-parser): Link/URL parser issues (#855)

* feat(fuselage): Adds wordbreak in Box Component (#853)

* Fixing URL/links parsing issues

* restoring files from base branch

* replacing backstick with single quotes

Co-authored-by: Douglas Fabris <[email protected]>

* fixing domainChar accepted chars (#861)

* temporarily removing emphasis support

Co-authored-by: Filipe Marins <[email protected]>
Co-authored-by: Hugo Costa <[email protected]>
Co-authored-by: Douglas Fabris <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants