Links having r/ or u/ as link text are not properly displayed
Checklist
- [x] I have used the search function for open and closed issues to see if someone else has already submitted the same bug report.
- [x] I will describe the problem with as much detail as possible.
- [x] If the bug only occurs with a certain link, post, image..., I will include the URL.
App version
8.3.0-beta3
Where did you get the app from
Other
Android version
15
Device model
No response
First occurred
No response
Steps to reproduce
- Create post/comment in the following formats:
a.[Example r/SubName](AnyUrl)
b.[Example u/UserName](AnyUrl)
Example post, link, markdown...
https://www.reddit.com/r/Infinity_For_Reddit/comments/1uw60sn/links_having_r_or_u_as_link_text_are_not_properly/
Expected behaviour
The link is properly displayed/rendered
Current behaviour
The link is displayed as plain text.
Also for the url, the end bracket is combined with it. On clicking, it is this incorrect url being opened in the browser.
Found a solution by tweaking the patterns to recognize r/ and u/ links in https://github.com/Docile-Alligator/Infinity-For-Reddit/blob/6b6f7bb0197bcb4cf907686e5c315dfc17da01e0/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java#L76-L77 Changed it to:
Pattern.compile("(?<!\\[[^\\]\\n\\r]{0,60})(?<!\\S)/[rRuU]/[\\w-]+/{0,1}"),
Pattern.compile("(?<!\\[[^\\]\\n\\r]{0,60})(?<!\\S)[rRuU]/[\\w-]+/{0,1}"),
Seems to be ok now. Not sure if the regex is optimal tho. Are there more efficient options than a negative lookbehind?
Logs
No response
8.3.0-beta3:
The link is displayed wrong, and it doesn't actually take you to the link as it would normally. It opens it in a internal WebView.
The internal WebView:
His links have two different issues. Here is my test post with examples.
- He puts
r/Infinity_For_Redditin the title text. - He puts
/newon the end for the sort.
The first one causes it to be formatted wrong. The second one causes the internal WebView.
The raw text from my test post:
`Sort`:
[Test 1](https://www.reddit.com/r/Infinity_For_Reddit/new)
`No Sort`:
[Test 2](https://www.reddit.com/r/Infinity_For_Reddit/)
`Title and Sort`:
[Test r/Infinity_For_Reddit](https://www.reddit.com/r/Infinity_For_Reddit/new)
`Title`:
[Test r/Infinity_For_Reddit](https://www.reddit.com/r/Infinity_For_Reddit/)
`Sort with time`:
[Test 3](https://www.reddit.com/r/Infinity_For_Reddit/top?t=week)
# Even more examples
## Subreddit sort
[r/pics — hot](https://www.reddit.com/r/pics/hot)
[r/pics — new](https://www.reddit.com/r/pics/new)
[r/pics — rising](https://www.reddit.com/r/pics/rising)
[r/pics — top, no ?t=](https://www.reddit.com/r/pics/top)
[r/pics — top this week](https://www.reddit.com/r/pics/top/?t=week)
[r/pics — controversial all](https://www.reddit.com/r/pics/controversial/?t=all)
## u_username (user-as-subreddit)
[r/u_spez — top](https://www.reddit.com/r/u_spez/top)
## Multireddit (replace REALMULTI with a real public multi)
[u/spez's m/REALMULTI](https://www.reddit.com/user/spez/m/REALMULTI)
[u/spez m/REALMULTI — top week](https://www.reddit.com/user/spez/m/REALMULTI/top/?t=week)
[u-form: u/spez m/REALMULTI — new](https://www.reddit.com/u/spez/m/REALMULTI/new)
## /me/m/ (must be signed in; use a multi you own)
[my m/MYMULTI](https://www.reddit.com/me/m/MYMULTI)
[my m/MYMULTI — top](https://www.reddit.com/me/m/MYMULTI/top)
## User profile query-sort
[u/spez — top all](https://www.reddit.com/user/spez/?sort=top&t=all)
[u/spez — new](https://www.reddit.com/u/spez/?sort=new)
## User where-paths
[u/spez — comments tab](https://www.reddit.com/user/spez/comments)
[u/spez — submitted](https://www.reddit.com/user/spez/submitted)
[my upvoted](https://www.reddit.com/user/me/upvoted)
[my hidden](https://www.reddit.com/user/me/hidden)
## Subreddit-less post permalinks (/comments/{id}, /gallery/{id})
[bare /comments/{id}](https://www.reddit.com/comments/1uyh8pr)
[/comments/{id}/slug](https://www.reddit.com/comments/1uyh8pr/a_sign_in_philly_about_ice_oc)
[/gallery/{id} (real gallery post)](https://www.reddit.com/gallery/1uyj5sg)
My more robust fix from Continuum, but it is more complex. His proposed fix only fixes the first issue.
The title fix: https://github.com/cygnusx-1-org/continuum/commit/7692efdb
There are even more edge cases on the link types opening in a WebView. I am working finding and implementing all of them.
Here is my commit for all the other cases, but it won't apply cleanly. I am in the process of implementing NullAway from Uber.
https://github.com/cygnusx-1-org/continuum/commit/21df140cf08984fad176e9d99dd22a67a2e6e7ca
Thank you @edgan. Should the Webview one be listed in another separate bug issue then?
@Naattukaaran It is a choice. If it was just your original case I would probably leave it. But given all the other examples I found I would probably make a new one.
@edgan Thank you.
If I can ask... Could you make the bug report? I do not know much programming to understand all the changes in Continuum, on why the links open in webview. Would be more detailed for the dev, right?
If not, sorry, I will make a new one