mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Fix linkify for valid URLs with ... in the path.
This commit is contained in:
@@ -67,18 +67,18 @@ object LinkUtil {
|
|||||||
return LegalCharactersResult(false)
|
return LegalCharactersResult(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ILLEGAL_PERIODS_PATTERN.matcher(url).find()) {
|
|
||||||
return LegalCharactersResult(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
val matcher = DOMAIN_PATTERN.matcher(url)
|
val matcher = DOMAIN_PATTERN.matcher(url)
|
||||||
if (!matcher.matches()) {
|
if (!matcher.matches()) {
|
||||||
return LegalCharactersResult(false)
|
return LegalCharactersResult(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val domain = Objects.requireNonNull(matcher.group(2))
|
val domain = Objects.requireNonNull(matcher.group(2))
|
||||||
val cleanedDomain = domain.replace("\\.".toRegex(), "")
|
|
||||||
|
|
||||||
|
if (ILLEGAL_PERIODS_PATTERN.matcher(domain).find()) {
|
||||||
|
return LegalCharactersResult(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
val cleanedDomain = domain.replace("\\.".toRegex(), "")
|
||||||
return LegalCharactersResult(
|
return LegalCharactersResult(
|
||||||
isLegal = ALL_ASCII_PATTERN.matcher(cleanedDomain).matches() || ALL_NON_ASCII_PATTERN.matcher(cleanedDomain).matches(),
|
isLegal = ALL_ASCII_PATTERN.matcher(cleanedDomain).matches() || ALL_NON_ASCII_PATTERN.matcher(cleanedDomain).matches(),
|
||||||
domain = domain
|
domain = domain
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ public class LinkUtilTest_isLegal {
|
|||||||
{ "cool.localhost", true },
|
{ "cool.localhost", true },
|
||||||
{ "localhost", true },
|
{ "localhost", true },
|
||||||
{ "https://localhost", true },
|
{ "https://localhost", true },
|
||||||
{ "cool.test", true }
|
{ "cool.test", true },
|
||||||
|
{ "https://github.com/signalapp/Signal-Android/compare/v6.23.2...v6.23.3", true }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ class LinkUtilTest_isValidPreviewUrl(private val input: String, private val outp
|
|||||||
arrayOf("https://cool.test", false),
|
arrayOf("https://cool.test", false),
|
||||||
arrayOf("https://cool.invalid.com", true),
|
arrayOf("https://cool.invalid.com", true),
|
||||||
arrayOf("https://cool.localhost.signal.org", true),
|
arrayOf("https://cool.localhost.signal.org", true),
|
||||||
arrayOf("https://cool.test.blarg.gov", true)
|
arrayOf("https://cool.test.blarg.gov", true),
|
||||||
|
arrayOf("https://github.com/signalapp/Signal-Android/compare/v6.23.2...v6.23.3", true)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user