Signal-android: Link containing "$" get broken / cut after the $ sign.

Created on 7 Jan 2017  路  5Comments  路  Source: signalapp/Signal-Android

Example link : https://www.investing.com/news/economic-indicators/china-december-forex-reserves-fall-less-than-expected-to-$3.011-trillion-451716

Most helpful comment

I agree with closing this.

While Linkify does have functions for customizing matches and specifying different patterns for links, I can't see a way that the TextView exposes that. Certainly this is using the default behavior of Android to detect links.

As an aside, even if browsers accept it I'm not sure it's valid. The official definition for URL and URI disagree on the usage of $, with URL being more permissive even though conceptually the difference between them is that a URL actually needs to reference a concrete thing. As far as I can tell, Linkify must use the more recent URI specification which says that $ is a reserved symbol.

All 5 comments

Screenshot:

bildschirmfoto von 2017-01-09 19-59-26

I'll see if I can fix this.

So I investigated this problem and I do not think that this is an issue on Signal's side.

Signal uses the following code for finding links in messages:

<org.thoughtcrime.securesms.components.emoji.EmojiTextView
        ...
        android:autoLink="all"
        android:linksClickable="true" />

So it relies on TextView's autoLink attribute, which then uses the Linkify class.

Apparently, Linkify does not consider usage of the dollar sign $ to be allowed in an URL.

That means that if this is an issue at all, it is one on Android's side. I don't think there is an easy way to work around this in Signal. And I don't think a complicated workaround would be worth the trouble. Usually, special characters should be escaped by the browser when copying or sharing a link.

This is how the example link looks after escaping: https://www.investing.com/news/economic-indicators/china-december-forex-reserves-fall-less-than-expected-to-%243.011-trillion-451716

Now, of course, we could escape characters when the user sends a message to a contact, but that would mean that we would have to modify the text the user typed in and I don't like that!

After all, I vote for closing this issue for not being Signal's fault.

(Heck, why does a website use a dollar sign in a URL at all?!)

Thanks for investigating this, the $ is allowed so the url generator use the title of the text, which in this case is $3.011-trillion

I agree with closing this.

While Linkify does have functions for customizing matches and specifying different patterns for links, I can't see a way that the TextView exposes that. Certainly this is using the default behavior of Android to detect links.

As an aside, even if browsers accept it I'm not sure it's valid. The official definition for URL and URI disagree on the usage of $, with URL being more permissive even though conceptually the difference between them is that a URL actually needs to reference a concrete thing. As far as I can tell, Linkify must use the more recent URI specification which says that $ is a reserved symbol.

^ #6224 is more clearly one where a valid URL is poorly linkified. It looks like Linkify itself has a mechanism to specify any regexp for matching links, but autoLink does not. Possibly helpful post about using Linkify instead of autoLink: http://www.indelible.org/ink/android-linkify/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hiredgunhouse picture hiredgunhouse  路  3Comments

McLoo picture McLoo  路  3Comments

kwlg picture kwlg  路  3Comments

jult picture jult  路  3Comments

FeuRenard picture FeuRenard  路  3Comments