Bug 111772 - CFNetwork cache partitioning does not work properly on subdomains
Summary: CFNetwork cache partitioning does not work properly on subdomains
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac Unspecified
: P2 Normal
Assignee: Vicki Pfau
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-03-07 13:51 PST by Vicki Pfau
Modified: 2013-03-11 11:59 PDT (History)
4 users (show)

See Also:


Attachments
Patch (10.75 KB, patch)
2013-03-07 13:55 PST, Vicki Pfau
ddkilzer: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.