Merge pull request #7356 from hayaksi1/fix/4008-fediverse-handle-not-email

Do not linkify the server part of a fediverse handle as an email address
This commit is contained in:
Benoit Marty
2026-08-11 14:48:40 +02:00
committed by GitHub
2 changed files with 48 additions and 0 deletions
@@ -47,6 +47,11 @@ object LinkifyHelper {
val start = spannable.getSpanStart(urlSpan)
val end = spannable.getSpanEnd(urlSpan)
if (urlSpan !in oldURLSpans && spannable.isEmailInsideFediverseHandle(urlSpan, start)) {
spannable.removeSpan(urlSpan)
continue
}
// Try to avoid including trailing punctuation in the link.
// Since this might fail in some edge cases, we catch the exception and just use the original end index.
val newEnd = runCatchingExceptions {
@@ -82,6 +87,10 @@ object LinkifyHelper {
return spannable
}
private fun Spannable.isEmailInsideFediverseHandle(urlSpan: URLSpan, start: Int): Boolean {
return urlSpan.url.startsWith("mailto:") && start > 0 && this[start - 1] == '@'
}
private fun adjustLinkifiedUrlSpanEndIndex(spannable: Spannable, start: Int, end: Int): Int {
var end = end