Fixes #464 - Incorrect regex usage on extended grapheme clusters

This commit is contained in:
Stefan Ceriu
2023-02-09 09:50:18 +02:00
committed by Stefan Ceriu
parent 910a8e2067
commit 8932e83929
7 changed files with 64 additions and 20 deletions
@@ -49,7 +49,7 @@ enum MatrixEntityRegex: String {
// swiftlint:enable force_try
static func isMatrixHomeserver(_ homeserver: String) -> Bool {
guard let match = homeserverRegex.firstMatch(in: homeserver, range: .init(location: 0, length: homeserver.count)) else {
guard let match = homeserverRegex.firstMatch(in: homeserver) else {
return false
}
@@ -57,7 +57,7 @@ enum MatrixEntityRegex: String {
}
static func isMatrixUserIdentifier(_ identifier: String) -> Bool {
guard let match = userIdentifierRegex.firstMatch(in: identifier, range: .init(location: 0, length: identifier.count)) else {
guard let match = userIdentifierRegex.firstMatch(in: identifier) else {
return false
}
@@ -65,7 +65,7 @@ enum MatrixEntityRegex: String {
}
static func isMatrixRoomAlias(_ alias: String) -> Bool {
guard let match = roomAliasRegex.firstMatch(in: alias, range: .init(location: 0, length: alias.count)) else {
guard let match = roomAliasRegex.firstMatch(in: alias) else {
return false
}
@@ -73,7 +73,7 @@ enum MatrixEntityRegex: String {
}
static func isMatrixRoomIdentifier(_ identifier: String) -> Bool {
guard let match = roomIdentifierRegex.firstMatch(in: identifier, range: .init(location: 0, length: identifier.count)) else {
guard let match = roomIdentifierRegex.firstMatch(in: identifier) else {
return false
}
@@ -81,7 +81,7 @@ enum MatrixEntityRegex: String {
}
static func isMatrixEventIdentifier(_ identifier: String) -> Bool {
guard let match = eventIdentifierRegex.firstMatch(in: identifier, range: .init(location: 0, length: identifier.count)) else {
guard let match = eventIdentifierRegex.firstMatch(in: identifier) else {
return false
}