mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
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:
@@ -11,6 +11,7 @@ import SwiftUI
|
||||
struct Application: App {
|
||||
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
||||
@Environment(\.openURL) private var openURL
|
||||
@State private var alert: AlertInfo<ApplicationAlertType>?
|
||||
|
||||
private var appCoordinator: AppCoordinatorProtocol!
|
||||
|
||||
@@ -34,13 +35,21 @@ struct Application: App {
|
||||
if appCoordinator.handleDeepLink(url, isExternalURL: false) {
|
||||
return .handled
|
||||
}
|
||||
|
||||
if let confirmationParameters = url.confirmationParameters {
|
||||
alert = .init(id: .confirmURL,
|
||||
title: "Test",
|
||||
message: "Test",
|
||||
primaryButton: .init(title: "Confirm") { openURL(confirmationParameters.internalURL) },
|
||||
secondaryButton: .init(title: L10n.actionCancel, action: nil))
|
||||
|
||||
return .handled
|
||||
}
|
||||
|
||||
return .systemAction
|
||||
})
|
||||
.onOpenURL {
|
||||
if !appCoordinator.handleDeepLink($0, isExternalURL: true) {
|
||||
openURLInSystemBrowser($0)
|
||||
}
|
||||
.onOpenURL { url in
|
||||
openURL(url)
|
||||
}
|
||||
.onContinueUserActivity("INStartVideoCallIntent") { userActivity in
|
||||
// `INStartVideoCallIntent` is to be replaced with `INStartCallIntent`
|
||||
@@ -50,10 +59,17 @@ struct Application: App {
|
||||
.task {
|
||||
appCoordinator.start()
|
||||
}
|
||||
.alert(item: $alert)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func openURL(_ url: URL) {
|
||||
if !appCoordinator.handleDeepLink(url, isExternalURL: true) {
|
||||
openURLInSystemBrowser(url)
|
||||
}
|
||||
}
|
||||
|
||||
/// Hide the status bar so it doesn't interfere with the screenshot tests
|
||||
private var shouldHideStatusBar: Bool {
|
||||
@@ -81,3 +97,7 @@ struct Application: App {
|
||||
openURL(url)
|
||||
}
|
||||
}
|
||||
|
||||
enum ApplicationAlertType {
|
||||
case confirmURL
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user