Return a UTType identifier, not the UTType itself
The NSPasteboardWriting protocol requires the method -pasteboardPropertyListForType: to return a property list compatible type, thus the method is declared to have a return type of `id`, being effectively untyped. The caller does not verify that the call actually returns an object of a valid type for this purpose. It just stores it at the time. If there is any issue with the type of the value returned, it will show up later. In https://crrev.com/c/5738733, as part of macOS 11 modernization, the drag code was modernized so that an ivar, which used to hold an NSString, was modernized to hold a UTType. While most usage of that ivar was correctly updated, the fact that the return type of -pasteboardPropertyListForType: was `id` obscured the error that was introduced: that a UTType was returned from that method (a non- property list compatible type) rather than the required string (which is the desired property list compatible type). Therefore, fix the bug by returning the identifier rather than the UTType object. Fixed: 356666758 Change-Id: I088363b0250cb88bbd9ba5aa1cfbddf76ee7c748 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5752287 Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Commit-Queue: Leonard Grey <lgrey@chromium.org> Auto-Submit: Avi Drissman <avi@chromium.org> Reviewed-by: Leonard Grey <lgrey@chromium.org> Cr-Commit-Position: refs/heads/main@{#1335732}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
3daaf8e1b4
commit
ef1c0c55bc
@ -237,7 +237,7 @@
|
||||
// File instantiation promise.
|
||||
if ([type isEqualToString:base::apple::CFToNSPtrCast(
|
||||
kPasteboardTypeFilePromiseContent)]) {
|
||||
return _fileType;
|
||||
return _fileType.identifier;
|
||||
}
|
||||
if ([type isEqualToString:base::apple::CFToNSPtrCast(
|
||||
kPasteboardTypeFileURLPromise)]) {
|
||||
|
Reference in New Issue
Block a user