hanggrian / socialview

Android TextView and EditText with hashtag, mention, and hyperlink support
https://hendraanggrian.github.io/socialview/
Apache License 2.0
322 stars 81 forks source link

hyper link validation #92

Closed ErfanDP closed 10 months ago

ErfanDP commented 3 years ago

text view detects something like <> as hyperlink anyway to prevent that from happening?

hanggrian commented 3 years ago

You're right, <<hello.hi>> shouldn't be accepted as hyperlink. Hyperlink pattern responsible for this is Android's own code Patterns.WEB_URL. What we can do is change it using our own regex. Something like:

textView.setHyperlinkPattern(Pattern.compile("(?!<a\sname=\"([\w\s\d\-\.\#]+)\"><\/a>)<a\sname=\"([\w\s\d\-\.\#]+)\">(.*?)<\/a>"));

But I haven't tested it. I suppose a lot of test are required in order to replace Patterns.WEB_URL.

hanggrian commented 10 months ago

Closed for inactivity.