mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-08 22:33:26 +01:00
Fixes “Core Data error” when error is thrown while parsing Source JSON
‘NSCodingPath’ is an array of non-ObjC values, but because it’s an array the array itself conforms to NSSecureCoding via NSArray bridging. We now make sure every element in an array or dictionary also conforms to NSSecureCoding to keep it in an error’s userInfo for serialization.
This commit is contained in:
@@ -79,7 +79,20 @@ public extension NSError
|
||||
userInfo[NSDebugDescriptionErrorKey] = self.localizedDebugDescription
|
||||
// Remove userInfo values that don't conform to NSSecureEncoding.
|
||||
userInfo = userInfo.filter { (key, value) in
|
||||
return (value as AnyObject) is NSSecureCoding
|
||||
guard let secureCodable = value as? NSSecureCoding else { return false }
|
||||
|
||||
switch secureCodable
|
||||
{
|
||||
case let array as NSArray:
|
||||
let isSecureCodable = array.allSatisfy({ $0 is NSSecureCoding })
|
||||
return isSecureCodable
|
||||
|
||||
case let dictionary as NSDictionary:
|
||||
let isSecureCodable = dictionary.allValues.allSatisfy({ $0 is NSSecureCoding })
|
||||
return isSecureCodable
|
||||
|
||||
default: return true
|
||||
}
|
||||
}
|
||||
|
||||
// Sanitize underlying errors.
|
||||
|
||||
Reference in New Issue
Block a user