Changeset 65459 in webkit


Ignore:
Timestamp:
Aug 16, 2010 3:22:36 PM (14 years ago)
Author:
weinig@apple.com
Message:

Null CFURLRef returned from provisionalURL after searching on zillow.com
<rdar://problem/8261812>
https://bugs.webkit.org/show_bug.cgi?id=44072

Reviewed by Gavin Barraclough.

Conversion from WKURLRef to CFRURLRef was breaking on URLs using characters
such as '{'.

  • UIProcess/API/C/cf/WKURLCF.cpp:

(WKURLCopyCFURL): Use code similar to that found in KURLCFNet.cpp for conversion.

Location:
trunk/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r65457 r65459  
     12010-08-16  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        Null CFURLRef returned from provisionalURL after searching on zillow.com
     6        <rdar://problem/8261812>
     7        https://bugs.webkit.org/show_bug.cgi?id=44072
     8
     9        Conversion from WKURLRef to CFRURLRef was breaking on URLs using characters
     10        such as '{'.
     11
     12        * UIProcess/API/C/cf/WKURLCF.cpp:
     13        (WKURLCopyCFURL): Use code similar to that found in KURLCFNet.cpp for conversion.
     14
    1152010-08-16  Sam Weinig  <sam@webkit.org>
    216
  • trunk/WebKit2/UIProcess/API/C/cf/WKURLCF.cpp

    r64232 r65459  
    3131#include <wtf/RefPtr.h>
    3232#include <wtf/RetainPtr.h>
     33#include <wtf/text/CString.h>
    3334
    3435using namespace WebCore;
     
    4546    ASSERT(!toWK(URLRef)->string().isNull());
    4647
    47     // We first create a CFString and then create the CFURL from it. This will ensure that the CFURL is stored in
     48    // We first create a CString and then create the CFURL from it. This will ensure that the CFURL is stored in
    4849    // UTF-8 which uses less memory and is what WebKit clients might expect.
    49     RetainPtr<CFStringRef> urlString(AdoptCF, CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(toWK(URLRef)->string().characters()),
    50                                                                                 toWK(URLRef)->string().length(), kCFAllocatorNull));
    5150
    52     return CFURLCreateWithString(allocatorRef, urlString.get(), 0);
     51    // This pattern of using UTF-8 and then falling back to Latin1 on failure matches KURL::createCFString with the
     52    // major differnce being that KURL does not do a UTF-8 conversion and instead chops off the high bits of the UTF-16
     53    // character sequence.
     54
     55    CString buffer = toWK(URLRef)->string().utf8();
     56    CFURLRef result = CFURLCreateAbsoluteURLWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(buffer.data()), buffer.length(), kCFStringEncodingUTF8, 0, true);
     57    if (!result)
     58        result = CFURLCreateAbsoluteURLWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(buffer.data()), buffer.length(), kCFStringEncodingISOLatin1, 0, true);
     59    return result;
    5360}
Note: See TracChangeset for help on using the changeset viewer.