Bug 111772

Summary: CFNetwork cache partitioning does not work properly on subdomains
Product: WebKit Reporter: Vicki Pfau <jeffrey+webkit>
Component: Page LoadingAssignee: Vicki Pfau <jeffrey+webkit>
Status: RESOLVED FIXED    
Severity: Normal CC: ddkilzer, japhet, mjs, webkit.review.bot
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: Unspecified   
Attachments:
Description Flags
Patch ddkilzer: review+

Description Vicki Pfau 2013-03-07 13:51:16 PST
Currently, the CFNetwork cache partition is initialized on NSURLRequests with the wrong partition name--it uses the full domain instead of just the top privately-controlled domain. This causes the partitions to get out of sync and/or just not work properly.
Comment 1 Vicki Pfau 2013-03-07 13:55:28 PST
Created attachment 192082 [details]
Patch
Comment 2 David Kilzer (:ddkilzer) 2013-03-07 15:41:09 PST
Comment on attachment 192082 [details]
Patch

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

r=me

> Source/WebCore/platform/network/mac/ResourceRequestMac.mm:193
> +    String partition = cachePartition();
> +    if (!partition.isNull() && !partition.isEmpty())
> +        [NSURLProtocol setProperty:[NSString stringWithUTF8String:partition.utf8().data()] forKey:(NSString *)wkCachePartitionKey() inRequest:nsRequest];

This would be easier to read if you pulled out the UTF-8 string conversion as a separate local variable:

        NSString *partitionValue = [NSString stringWithUTF8String:partition.utf8().data()];
        [NSURLProtocol setProperty:partitionValue forKey:(NSString *)wkCachePartitionKey() inRequest:nsRequest];
Comment 3 Vicki Pfau 2013-03-07 16:54:02 PST
<rdar://problem/13374125>
Comment 4 Vicki Pfau 2013-03-07 17:13:49 PST
Committed r145161: <http://trac.webkit.org/changeset/145161>
Comment 5 Darin Adler 2013-03-10 14:50:27 PDT
Comment on attachment 192082 [details]
Patch

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

>> Source/WebCore/platform/network/mac/ResourceRequestMac.mm:193
>> +        [NSURLProtocol setProperty:[NSString stringWithUTF8String:partition.utf8().data()] forKey:(NSString *)wkCachePartitionKey() inRequest:nsRequest];
> 
> This would be easier to read if you pulled out the UTF-8 string conversion as a separate local variable:
> 
>         NSString *partitionValue = [NSString stringWithUTF8String:partition.utf8().data()];
>         [NSURLProtocol setProperty:partitionValue forKey:(NSString *)wkCachePartitionKey() inRequest:nsRequest];

Why is UTF-8 involved at all? Why not just cachedPartition().nsString()?
Comment 6 Vicki Pfau 2013-03-11 11:59:59 PDT
(In reply to comment #5)
> (From update of attachment 192082 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=192082&action=review
> 
> >> Source/WebCore/platform/network/mac/ResourceRequestMac.mm:193
> >> +        [NSURLProtocol setProperty:[NSString stringWithUTF8String:partition.utf8().data()] forKey:(NSString *)wkCachePartitionKey() inRequest:nsRequest];
> > 
> > This would be easier to read if you pulled out the UTF-8 string conversion as a separate local variable:
> > 
> >         NSString *partitionValue = [NSString stringWithUTF8String:partition.utf8().data()];
> >         [NSURLProtocol setProperty:partitionValue forKey:(NSString *)wkCachePartitionKey() inRequest:nsRequest];
> 
> Why is UTF-8 involved at all? Why not just cachedPartition().nsString()?

It's an unfortunate workaround for <rdar://problem/13361941>, which CFNetwork has said they're not going to fix.