Changeset 189200 in webkit


Ignore:
Timestamp:
Aug 31, 2015 5:29:24 PM (9 years ago)
Author:
Brent Fulgham
Message:

[Win] WebKit cannot load pages based on "file://" URLs
https://bugs.webkit.org/show_bug.cgi?id=148596
<rdar://problem/22432585>

Reviewed by Dean Jackson.

  • platform/URL.cpp:

(WebCore::URL::URL): Work around bug that causes this assertion to fire on
the Apple Windows build.

  • platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp:

(WebCore::adjustMIMETypeIfNecessary): Added. If the URL is for a local file,
determine the MIME type based on extension. Otherwise use the default MIME type.
(WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didReceiveResponse): If
the CFURLResponse has no MIME type, call 'adjustMIMETypeIfNecessary'.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r189198 r189200  
     12015-08-31  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Win] WebKit cannot load pages based on "file://" URLs
     4        https://bugs.webkit.org/show_bug.cgi?id=148596
     5        <rdar://problem/22432585>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * platform/URL.cpp:
     10        (WebCore::URL::URL): Work around bug that causes this assertion to fire on
     11        the Apple Windows build.
     12        * platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp:
     13        (WebCore::adjustMIMETypeIfNecessary): Added. If the URL is for a local file,
     14        determine the MIME type based on extension. Otherwise use the default MIME type.
     15        (WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didReceiveResponse): If
     16        the CFURLResponse has no MIME type, call 'adjustMIMETypeIfNecessary'.
     17
    1182015-08-31  Chris Dumez  <cdumez@apple.com>
    219
  • trunk/Source/WebCore/platform/URL.cpp

    r183901 r189200  
    433433{
    434434    parse(url);
     435#if OS(WINDOWS)
     436    // FIXME(148598): Work around Windows local file handling bug in CFNetwork
     437    ASSERT(isLocalFile() || url == m_string);
     438#else
    435439    ASSERT(url == m_string);
     440#endif
    436441}
    437442
  • trunk/Source/WebCore/platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp

    r185971 r189200  
    11/*
    2  * Copyright (C) 2004-2013 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2004-2013, 2015 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    110110    CFURLResponseSetMIMEType(response, defaultMIMETypeString);
    111111}
     112
     113static void adjustMIMETypeIfNecessary(CFURLResponseRef cfResponse)
     114{
     115    RetainPtr<CFStringRef> result = CFURLResponseGetMIMEType(cfResponse);
     116    RetainPtr<CFStringRef> originalResult = result;
     117
     118    if (!result) {
     119        CFURLRef cfURL = CFURLResponseGetURL(cfResponse);
     120        URL url(cfURL);
     121        if (url.isLocalFile()) {
     122            String mimeType = mimeTypeFromURL(url);
     123            result = mimeType.createCFString().leakRef();
     124        }
     125    }
     126
     127    if (!result) {
     128        static CFStringRef defaultMIMETypeString = WebCore::defaultMIMEType().createCFString().leakRef();
     129        result = defaultMIMETypeString;
     130    }
     131
     132    if (result != originalResult)
     133        CFURLResponseSetMIMEType(cfResponse, result.get());
     134}
    112135#endif // !PLATFORM(COCOA)
    113136
     
    132155#endif // !PLATFORM(IOS)
    133156#else
     157    if (!CFURLResponseGetMIMEType(cfResponse))
     158        adjustMIMETypeIfNecessary(cfResponse);
     159
    134160    if (!CFURLResponseGetMIMEType(cfResponse)) {
    135161        // We should never be applying the default MIMEType if we told the networking layer to do content sniffing for handle.
Note: See TracChangeset for help on using the changeset viewer.