Skip to content
Snippets Groups Projects
Commit 8b6ba52e authored by Pavan Koushik Nellore's avatar Pavan Koushik Nellore
Browse files

LinkPreview: add email address check

Fix incorrect URL matches from emails. Matcher returns
only the domain (e.g. gmail.com), so the existing  email
check didn't work as expected.

GitLab: #1383
Change-Id: Ifa13910fbb08863c4396033f66ddf5d22d4d883e
parent 85bc79a6
No related branches found
No related tags found
No related merge requests found
...@@ -14,9 +14,10 @@ object LinkPreview { ...@@ -14,9 +14,10 @@ object LinkPreview {
val matcher = PatternsCompat.AUTOLINK_WEB_URL.matcher(input) val matcher = PatternsCompat.AUTOLINK_WEB_URL.matcher(input)
while (matcher.find()) { while (matcher.find()) {
val word = matcher.group() val word = matcher.group()
val start = matcher.start()
if (!word.startsWith("http://", ignoreCase = true) && !word.startsWith("https://", ignoreCase = true)) { if (!word.startsWith("http://", ignoreCase = true) && !word.startsWith("https://", ignoreCase = true)) {
if (PatternsCompat.EMAIL_ADDRESS.matcher(word).matches()) { if (start > 0 && input[start - 1] == '@') {
continue continue // Skip email addresses
} }
result.add("https://$word") result.add("https://$word")
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment