Infinity-For-Reddit icon indicating copy to clipboard operation
Infinity-For-Reddit copied to clipboard

Links having r/ or u/ as link text are not properly displayed

Open Naattukaaran opened this issue 4 months ago • 8 comments

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

  1. 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

Naattukaaran avatar Jul 14 '26 11:07 Naattukaaran

8.3.0-beta3: Image

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.

edgan avatar Jul 17 '26 05:07 edgan

The internal WebView: Image

edgan avatar Jul 17 '26 05:07 edgan

His links have two different issues. Here is my test post with examples.

  1. He puts r/Infinity_For_Reddit in the title text.
  2. He puts /new on 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)

&nbsp;
&nbsp;

[r/pics — new](https://www.reddit.com/r/pics/new)

&nbsp;
&nbsp;

[r/pics — rising](https://www.reddit.com/r/pics/rising)

&nbsp;
&nbsp;

[r/pics — top, no ?t=](https://www.reddit.com/r/pics/top)

&nbsp;
&nbsp;

[r/pics — top this week](https://www.reddit.com/r/pics/top/?t=week)

&nbsp;
&nbsp;

[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)

&nbsp;
&nbsp;

[u/spez m/REALMULTI — top week](https://www.reddit.com/user/spez/m/REALMULTI/top/?t=week)

&nbsp;
&nbsp;

[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)

&nbsp;
&nbsp;

[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)

&nbsp;
&nbsp;

[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)

&nbsp;
&nbsp;

[u/spez — submitted](https://www.reddit.com/user/spez/submitted)

&nbsp;
&nbsp;

[my upvoted](https://www.reddit.com/user/me/upvoted)

&nbsp;
&nbsp;

[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)

&nbsp;
&nbsp;

[/comments/{id}/slug](https://www.reddit.com/comments/1uyh8pr/a_sign_in_philly_about_ice_oc)

&nbsp;
&nbsp;

[/gallery/{id} (real gallery post)](https://www.reddit.com/gallery/1uyj5sg)

edgan avatar Jul 17 '26 06:07 edgan

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.

edgan avatar Jul 17 '26 07:07 edgan

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

edgan avatar Jul 17 '26 09:07 edgan

Thank you @edgan. Should the Webview one be listed in another separate bug issue then?

Naattukaaran avatar Jul 17 '26 12:07 Naattukaaran

@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 avatar Jul 17 '26 22:07 edgan

@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

Naattukaaran avatar Jul 18 '26 18:07 Naattukaaran