Bug 215718 - PlatformPasteboard::getPathnamesForType() assumes the pasteboard type property list is an NSArray of NSStrings
Summary: PlatformPasteboard::getPathnamesForType() assumes the pasteboard type propert...
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kate Cheney
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-08-20 17:03 PDT by Kate Cheney
Modified: 2020-09-08 14:06 PDT (History)
3 users (show)

See Also:


Attachments
Patch (5.28 KB, patch)
2020-08-20 17:11 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff
Patch (5.68 KB, patch)
2020-09-08 13:17 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kate Cheney 2020-08-20 17:03:31 PDT
This is not always the case, so we should probably handle other cases
Comment 1 Kate Cheney 2020-08-20 17:04:00 PDT
<rdar://problem/67505327>
Comment 2 Kate Cheney 2020-08-20 17:11:01 PDT
Created attachment 406979 [details]
Patch
Comment 3 Radar WebKit Bug Importer 2020-08-27 17:09:49 PDT
<rdar://problem/67906582>
Comment 4 Kate Cheney 2020-09-08 13:17:01 PDT
Created attachment 408262 [details]
Patch
Comment 5 Darin Adler 2020-09-08 13:25:01 PDT
Comment on attachment 408262 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=408262&action=review

> Source/WebCore/platform/mac/PlatformPasteboardMac.mm:113
> +        if ([[paths objectAtIndex:0] isKindOfClass:[NSArray class]]) {
> +            [paths enumerateObjectsUsingBlock:^(NSArray *plistEntry, NSUInteger, BOOL *) {
> +                pathnames.appendVector(makeVector<String>(plistEntry));
> +            }];
> +            return;
> +        }

This is very interesting. What is the semantics of this array of arrays? Why is it correct to flatten out this array of arrays into a single vector of strings? Are all the strings in all these arrays pathnames? Why is this structured that way?

(Separately, sadly appendVector(makeVector) is not particularly efficient, and we might want to improve that later.)
Comment 6 Kate Cheney 2020-09-08 13:43:06 PDT
(In reply to Darin Adler from comment #5)
> Comment on attachment 408262 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=408262&action=review
> 
> > Source/WebCore/platform/mac/PlatformPasteboardMac.mm:113
> > +        if ([[paths objectAtIndex:0] isKindOfClass:[NSArray class]]) {
> > +            [paths enumerateObjectsUsingBlock:^(NSArray *plistEntry, NSUInteger, BOOL *) {
> > +                pathnames.appendVector(makeVector<String>(plistEntry));
> > +            }];
> > +            return;
> > +        }
> 
> This is very interesting. What is the semantics of this array of arrays? Why
> is it correct to flatten out this array of arrays into a single vector of
> strings? Are all the strings in all these arrays pathnames? Why is this
> structured that way?

I noticed this while investigating another bug, but haven't actually been able to reproduce any user-facing impact (trying now). I thought it was strange that WebKit itself sets property lists of NSArrays of NSArrays but here assumes the type is an NSArray of NSStrings. Maybe we don't care about that case in PlatformPasteboard::getPathnamesForType().

> 
> (Separately, sadly appendVector(makeVector) is not particularly efficient,
> and we might want to improve that later.)

Noted, I did not know it was inefficient.
Comment 7 Kate Cheney 2020-09-08 14:06:03 PDT
(In reply to katherine_cheney from comment #6)
> (In reply to Darin Adler from comment #5)
> > Comment on attachment 408262 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=408262&action=review
> > 
> > > Source/WebCore/platform/mac/PlatformPasteboardMac.mm:113
> > > +        if ([[paths objectAtIndex:0] isKindOfClass:[NSArray class]]) {
> > > +            [paths enumerateObjectsUsingBlock:^(NSArray *plistEntry, NSUInteger, BOOL *) {
> > > +                pathnames.appendVector(makeVector<String>(plistEntry));
> > > +            }];
> > > +            return;
> > > +        }
> > 
> > This is very interesting. What is the semantics of this array of arrays? Why
> > is it correct to flatten out this array of arrays into a single vector of
> > strings? Are all the strings in all these arrays pathnames? Why is this
> > structured that way?
> 
> I noticed this while investigating another bug, but haven't actually been
> able to reproduce any user-facing impact (trying now). I thought it was
> strange that WebKit itself sets property lists of NSArrays of NSArrays but
> here assumes the type is an NSArray of NSStrings. Maybe we don't care about
> that case in PlatformPasteboard::getPathnamesForType().
> 

Actually, looking at other parts of the code, you're right. PlatformPasteboard::getPathnamesForType() should only need to handle the case of NSArray of NSStrings, because the NSArray of NSArray case is not pathname-related. Closing this bug.