phishing alert implementation

we now check when building the string through the `AttributedStringBuilder` if a URL is actually hiding a different link, if so, we create a custom URL that contains both the external and the internal URL to advise the user through an Alert about the risk
This commit is contained in:
Mauro Romito
2025-03-12 17:48:21 +01:00
committed by Mauro
parent f248bdfd92
commit 516892ed7b
8 changed files with 199 additions and 25 deletions
@@ -137,11 +137,14 @@ struct MessageText: UIViewRepresentable {
return true
}
}
@available(iOS 17.0, *)
func textView(_ textView: UITextView, menuConfigurationFor textItem: UITextItem, defaultMenu: UIMenu) -> UITextItem.MenuConfiguration? {
switch textItem.content {
case let .link(url):
guard !url.requiresConfirmation else {
return nil
}
// We don't want to show a URL preview for permalinks
let isPermalink = parseMatrixEntityFrom(uri: url.absoluteString) != nil
return .init(preview: isPermalink ? nil : .default, menu: defaultMenu)