mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +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:
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright 2025 New Vector Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension CharacterSet {
|
||||
private static let urlAllowedSets: [CharacterSet] = [
|
||||
.urlUserAllowed,
|
||||
.urlPasswordAllowed,
|
||||
.urlHostAllowed,
|
||||
.urlPathAllowed,
|
||||
.urlQueryAllowed,
|
||||
.urlFragmentAllowed
|
||||
]
|
||||
|
||||
static let urlAllowedCharacters: CharacterSet = {
|
||||
// Start by including hash, which isn't in any URL set
|
||||
// Then include all URL-legal characters
|
||||
var result = CharacterSet(charactersIn: "#")
|
||||
for set in urlAllowedSets {
|
||||
result.formUnion(set)
|
||||
}
|
||||
return result
|
||||
}()
|
||||
|
||||
static let matrixUserIDAllowedCharacters = CharacterSet(charactersIn: "abcdefghijklmnopqrstuvwxyz0123456789._=-/@:")
|
||||
}
|
||||
Reference in New Issue
Block a user