Re: Verbose warning splurged to the log with Secure Coding (dearchiving) -- can they be serious?
Graham Cox
Hi Glenn,
toggle quoted message
Show quoted text
This seemed like a perfectly fine idea in this case, so I tried it. Now I get a new message spewed to the log: 2022-02-24 20:50:13.158117+1100 GCSimpleContainers[26354:31119213] [general] *** -[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSString' (0x7ff85c670920) [/System/Library/Frameworks/Foundation.framework]' for key 'data', even though it was not explicitly included in the client allowed classes set: '{( "'__NSCFConstantString' (0x7ff85c645908) [/System/Library/Frameworks/CoreFoundation.framework]" )}'. This will be disallowed in the future. This happens for the line that decodes the payload object, which happens to be a string. My code is: Class dataClass = NSClassFromString([coder decodeObjectOfClass:[NSString class] forKey:@"data_class"]); //<—— this is OK self.data = [coder decodeObjectOfClass:dataClass forKey:@"data”]; //<— this is not The actual class is __NSCFConstantString, rather than just a generic NSString, that seems to be what it is complaining about — if I change it to use [NSString class] it’s fine. Since the archive originally wrote the result of NSStringFromClass(), it will of course write the explicit class rather than the more general umbrella class of a cluster. Can you think of a simple solution for this, in general? —G.
|
|