Changeset 76041 in webkit


Ignore:
Timestamp:
Jan 18, 2011 11:15:03 AM (13 years ago)
Author:
Adam Roben
Message:

Call alternate CFHTTPCookie functions if available

Fixes <http://webkit.org/b/52637> <rdar://problem/8878984>.

Reviewed by Darin Adler.

  • platform/network/cf/CookieJarCFNet.cpp: Added soft-linking macros to

pull in the alternate CFHTTPCookie functions.

(WebCore::cookieDomain):
(WebCore::cookieExpirationTime):
(WebCore::cookieName):
(WebCore::cookiePath):
(WebCore::cookieValue):
Added these wrappers around the CFHTTPCookie functions. We call the
alternate functions if they exist, otherwise fall back to the current
functions.

(WebCore::filterCookies):
(WebCore::getRawCookies):
(WebCore::deleteCookie):
Changed to use the wrapper functions.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r76039 r76041  
     12011-01-18  Adam Roben  <aroben@apple.com>
     2
     3        Call alternate CFHTTPCookie functions if available
     4
     5        Fixes <http://webkit.org/b/52637> <rdar://problem/8878984>.
     6
     7        Reviewed by Darin Adler.
     8
     9        * platform/network/cf/CookieJarCFNet.cpp: Added soft-linking macros to
     10        pull in the alternate CFHTTPCookie functions.
     11
     12        (WebCore::cookieDomain):
     13        (WebCore::cookieExpirationTime):
     14        (WebCore::cookieName):
     15        (WebCore::cookiePath):
     16        (WebCore::cookieValue):
     17        Added these wrappers around the CFHTTPCookie functions. We call the
     18        alternate functions if they exist, otherwise fall back to the current
     19        functions.
     20
     21        (WebCore::filterCookies):
     22        (WebCore::getRawCookies):
     23        (WebCore::deleteCookie):
     24        Changed to use the wrapper functions.
     25
    1262011-01-18  Martin Robinson  <mrobinson@igalia.com>
    227
  • trunk/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp

    r74943 r76041  
    3535#include "PlatformString.h"
    3636#include "ResourceHandle.h"
     37#include "SoftLinking.h"
    3738#include <CFNetwork/CFHTTPCookiesPriv.h>
    3839#include <CoreFoundation/CoreFoundation.h>
     
    4546static const CFStringRef s_cookieCF = CFSTR("Cookie");
    4647
     48#ifdef DEBUG_ALL
     49SOFT_LINK_DEBUG_LIBRARY(CFNetwork)
     50#else
     51SOFT_LINK_LIBRARY(CFNetwork)
     52#endif
     53
     54SOFT_LINK_OPTIONAL(CFNetwork, CFHTTPCookieCopyDomain, CFStringRef, __cdecl, (CFHTTPCookieRef))
     55SOFT_LINK_OPTIONAL(CFNetwork, CFHTTPCookieGetExpirationTime, CFAbsoluteTime, __cdecl, (CFHTTPCookieRef))
     56SOFT_LINK_OPTIONAL(CFNetwork, CFHTTPCookieCopyName, CFStringRef, __cdecl, (CFHTTPCookieRef))
     57SOFT_LINK_OPTIONAL(CFNetwork, CFHTTPCookieCopyPath, CFStringRef, __cdecl, (CFHTTPCookieRef))
     58SOFT_LINK_OPTIONAL(CFNetwork, CFHTTPCookieCopyValue, CFStringRef, __cdecl, (CFHTTPCookieRef))
     59
     60static inline RetainPtr<CFStringRef> cookieDomain(CFHTTPCookieRef cookie)
     61{
     62    if (CFHTTPCookieCopyDomainPtr())
     63        return RetainPtr<CFStringRef>(AdoptCF, CFHTTPCookieCopyDomainPtr()(cookie));
     64    return CFHTTPCookieGetDomain(cookie);
     65}
     66
     67static inline CFAbsoluteTime cookieExpirationTime(CFHTTPCookieRef cookie)
     68{
     69    if (CFHTTPCookieGetExpirationTimePtr())
     70        return CFHTTPCookieGetExpirationTimePtr()(cookie);
     71    return CFDateGetAbsoluteTime(CFHTTPCookieGetExpiratonDate(cookie));
     72}
     73
     74static inline RetainPtr<CFStringRef> cookieName(CFHTTPCookieRef cookie)
     75{
     76    if (CFHTTPCookieCopyNamePtr())
     77        return RetainPtr<CFStringRef>(AdoptCF, CFHTTPCookieCopyNamePtr()(cookie));
     78    return CFHTTPCookieGetName(cookie);
     79}
     80
     81static inline RetainPtr<CFStringRef> cookiePath(CFHTTPCookieRef cookie)
     82{
     83    if (CFHTTPCookieCopyPathPtr())
     84        return RetainPtr<CFStringRef>(AdoptCF, CFHTTPCookieCopyPathPtr()(cookie));
     85    return CFHTTPCookieGetPath(cookie);
     86}
     87
     88static inline RetainPtr<CFStringRef> cookieValue(CFHTTPCookieRef cookie)
     89{
     90    if (CFHTTPCookieCopyValuePtr())
     91        return RetainPtr<CFStringRef>(AdoptCF, CFHTTPCookieCopyValuePtr()(cookie));
     92    return CFHTTPCookieGetValue(cookie);
     93}
     94
    4795static RetainPtr<CFArrayRef> filterCookies(CFArrayRef unfilteredCookies)
    4896{
     
    56104        // that, but we also need to avoid sending cookies that were previously stored, and
    57105        // there's no harm to doing this check because such a cookie is never valid.
    58         if (!CFStringGetLength(CFHTTPCookieGetName(cookie)))
     106        if (!CFStringGetLength(cookieName(cookie).get()))
    59107            continue;
    60108
     
    148196    for (CFIndex i = 0; i < count; i++) {
    149197       CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(cookiesCF.get(), i);
    150        String name = CFHTTPCookieGetName(cookie);
    151        String value = CFHTTPCookieGetValue(cookie);
    152        String domain = CFHTTPCookieGetDomain(cookie);
    153        String path = CFHTTPCookieGetPath(cookie);
    154 
    155        double expires = (CFDateGetAbsoluteTime(CFHTTPCookieGetExpiratonDate(cookie)) + kCFAbsoluteTimeIntervalSince1970) * 1000;
     198       String name = cookieName(cookie).get();
     199       String value = cookieValue(cookie).get();
     200       String domain = cookieDomain(cookie).get();
     201       String path = cookiePath(cookie).get();
     202
     203       double expires = (cookieExpirationTime(cookie) + kCFAbsoluteTimeIntervalSince1970) * 1000;
    156204
    157205       bool httpOnly = CFHTTPCookieIsHTTPOnly(cookie);
     
    179227    for (CFIndex i = 0; i < count; i++) {
    180228        CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(cookiesCF.get(), i);
    181         String cookieName = CFHTTPCookieGetName(cookie);
    182         if (cookieName == name) {
     229        if (String(cookieName(cookie).get()) == name) {
    183230            CFHTTPCookieStorageDeleteCookie(cookieStorage, cookie);
    184231            break;
Note: See TracChangeset for help on using the changeset viewer.