summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadSettings/PersistentAccessMethod.swift
diff options
context:
space:
mode:
authorJon Petersson <jon.petersson@kvadrat.se>2024-05-13 13:41:50 +0200
committerEmīls <emils@mullvad.net>2024-05-13 17:42:20 +0200
commit9d4c27f7caec0741bb682ea81c70fadd094ceb8e (patch)
treefef18d937173bed178e2aa2ea8bc1dbaa8ebffb4 /ios/MullvadSettings/PersistentAccessMethod.swift
parent2378efb3314ec5548a1c7c9b8629a4773650e056 (diff)
downloadmullvadvpn-9d4c27f7caec0741bb682ea81c70fadd094ceb8e.tar.xz
mullvadvpn-9d4c27f7caec0741bb682ea81c70fadd094ceb8e.zip
Fix user input string validation
Diffstat (limited to 'ios/MullvadSettings/PersistentAccessMethod.swift')
-rw-r--r--ios/MullvadSettings/PersistentAccessMethod.swift13
1 files changed, 13 insertions, 0 deletions
diff --git a/ios/MullvadSettings/PersistentAccessMethod.swift b/ios/MullvadSettings/PersistentAccessMethod.swift
index 9d67ce849f..2194167a8e 100644
--- a/ios/MullvadSettings/PersistentAccessMethod.swift
+++ b/ios/MullvadSettings/PersistentAccessMethod.swift
@@ -40,6 +40,19 @@ public struct PersistentAccessMethod: Identifiable, Codable, Equatable {
self.proxyConfiguration = proxyConfiguration
}
+ public init(from decoder: any Decoder) throws {
+ let container = try decoder.container(keyedBy: CodingKeys.self)
+
+ self.id = try container.decode(UUID.self, forKey: .id)
+ self.isEnabled = try container.decode(Bool.self, forKey: .isEnabled)
+ self.proxyConfiguration = try container.decode(PersistentProxyConfiguration.self, forKey: .proxyConfiguration)
+
+ // Added after release of API access methods feature. There was previously no limitation on text input length,
+ // so this formatting has been added to prevent already stored names from being too long when displayed.
+ let name = try container.decode(String.self, forKey: .name)
+ self.name = NameInputFormatter.format(name)
+ }
+
public static func == (lhs: Self, rhs: Self) -> Bool {
lhs.id == rhs.id
}