From f38db788a5268ac2fa57d91da17b09a57847efc0 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sat, 17 Jun 2023 21:49:31 +0800 Subject: [PATCH] PrefMgr // Upgrade sanity check for candidate keys. --- Source/Modules/PrefMgr_Core.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/Modules/PrefMgr_Core.swift b/Source/Modules/PrefMgr_Core.swift index 3b469af6..6ab7bb8c 100644 --- a/Source/Modules/PrefMgr_Core.swift +++ b/Source/Modules/PrefMgr_Core.swift @@ -296,10 +296,9 @@ public class PrefMgr: PrefMgrProtocol { @AppProperty(key: UserDef.kCandidateKeys.rawValue, defaultValue: kDefaultCandidateKeys) public var candidateKeys: String { didSet { - if candidateKeys != candidateKeys.deduplicated { - candidateKeys = candidateKeys.deduplicated - } - if !(6 ... 9).contains(candidateKeys.count) { + let optimized = candidateKeys.lowercased().deduplicated + if candidateKeys != optimized { candidateKeys = optimized } + if CandidateKey.validate(keys: candidateKeys) != nil { candidateKeys = Self.kDefaultCandidateKeys } }