Changeset 81732 in webkit


Ignore:
Timestamp:
Mar 22, 2011 5:33:48 PM (13 years ago)
Author:
andersca@apple.com
Message:

2011-03-22 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.

OBJECT element with DivX source is always downloaded
https://bugs.webkit.org/show_bug.cgi?id=56879

  • Plugins/WebBasePluginPackage.mm: (-[WebBasePluginPackage getPluginInfoFromPLists]): Always try to split every element in the "WebPluginExtensions" array, since the DivX plug-in specifies multiple file extensions in a single element.

2011-03-22 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.

OBJECT element with DivX source is always downloaded
https://bugs.webkit.org/show_bug.cgi?id=56879

  • Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm: (WebKit::getPluginInfoFromPropertyLists): Always try to split every element in the "WebPluginExtensions" array, since the DivX plug-in specifies multiple file extensions in a single element.


  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::pluginSupportsExtension): Add a new helper function.

(WebKit::WebFrameLoaderClient::objectContentType):
If we can't find the MIME for an extension, explicitly check if there's a plugin that claims to
handle the given extension.

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/mac/ChangeLog

    r81719 r81732  
     12011-03-22  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        OBJECT element with DivX source is always downloaded
     6        https://bugs.webkit.org/show_bug.cgi?id=56879
     7
     8        * Plugins/WebBasePluginPackage.mm:
     9        (-[WebBasePluginPackage getPluginInfoFromPLists]):
     10        Always try to split every element in the "WebPluginExtensions" array, since the DivX plug-in
     11        specifies multiple file extensions in a single element.
     12
    1132011-03-22  Brady Eidson  <beidson@apple.com>
    214
  • trunk/Source/WebKit/mac/Plugins/WebBasePluginPackage.mm

    r74446 r81732  
    3939#import <wtf/Threading.h>
    4040#import <wtf/Vector.h>
     41#import <wtf/text/CString.h>
    4142
    4243#import <WebKitSystemInterface.h>
     
    223224       
    224225        extensions = [[MIMEDictionary objectForKey:WebPluginExtensionsKey] _web_lowercaseStrings];
    225         for (NSUInteger i = 0; i < [extensions count]; ++i)
    226             mimeClassInfo.extensions.append((NSString *)[extensions objectAtIndex:i]);
     226        for (NSUInteger i = 0; i < [extensions count]; ++i) {
     227            // The DivX plug-in lists multiple extensions in a comma separated string instead of using
     228            // multiple array elements in the property list. Work around this here by splitting the
     229            // extension string into components.
     230            NSArray *extensionComponents = [[extensions objectAtIndex:i] componentsSeparatedByString:@","];
     231
     232            for (NSString *extension in extensionComponents)
     233                mimeClassInfo.extensions.append(extension);
     234        }
    227235
    228236        if ([extensions count] == 0)
  • trunk/Source/WebKit2/ChangeLog

    r81723 r81732  
     12011-03-22  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        OBJECT element with DivX source is always downloaded
     6        https://bugs.webkit.org/show_bug.cgi?id=56879
     7
     8        * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
     9        (WebKit::getPluginInfoFromPropertyLists):
     10        Always try to split every element in the "WebPluginExtensions" array, since the DivX plug-in
     11        specifies multiple file extensions in a single element.
     12       
     13        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     14        (WebKit::pluginSupportsExtension):
     15        Add a new helper function.
     16
     17        (WebKit::WebFrameLoaderClient::objectContentType):
     18        If we can't find the MIME for an extension, explicitly check if there's a plugin that claims to
     19        handle the given extension.
     20
    1212011-03-22  Brady Eidson  <beidson@apple.com>
    222
  • trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm

    r81705 r81732  
    143143            if (!extension || CFGetTypeID(extension) != CFStringGetTypeID())
    144144                continue;
    145            
    146             mimeClassInfo.extensions.append(String(extension).lower());
     145
     146            // The DivX plug-in lists multiple extensions in a comma separated string instead of using
     147            // multiple array elements in the property list. Work around this here by splitting the
     148            // extension string into components.
     149            Vector<String> extensionComponents;
     150            String(extension).lower().split(',', extensionComponents);
     151
     152            for (size_t i = 0; i < extensionComponents.size(); ++i)
     153                mimeClassInfo.extensions.append(extensionComponents[i]);
    147154        }
    148155
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r81535 r81732  
    12561256}
    12571257
     1258static bool pluginSupportsExtension(PluginData* pluginData, const String& extension)
     1259{
     1260    ASSERT(extension.lower() == extension);
     1261
     1262    for (size_t i = 0; i < pluginData->mimes().size(); ++i) {
     1263        const MimeClassInfo& mimeClassInfo = pluginData->mimes()[i];
     1264
     1265        if (mimeClassInfo.extensions.contains(extension))
     1266            return true;
     1267    }
     1268    return false;
     1269}
     1270
    12581271ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const String& mimeTypeIn)
    12591272{
     
    12621275
    12631276    String mimeType = mimeTypeIn;
    1264     if (mimeType.isEmpty())
    1265         mimeType = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1));
     1277    if (mimeType.isEmpty()) {
     1278        String extension = url.path().substring(url.path().reverseFind('.') + 1).lower();
     1279
     1280        // Try to guess the MIME type from the extension.
     1281        mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension);
     1282
     1283        if (mimeType.isEmpty()) {
     1284            // Check if there's a plug-in around that can handle the extension.
     1285            if (WebPage* webPage = m_frame->page()) {
     1286                if (PluginData* pluginData = webPage->corePage()->pluginData()) {
     1287                    if (pluginSupportsExtension(pluginData, extension))
     1288                        return ObjectContentNetscapePlugin;
     1289                }
     1290            }
     1291        }
     1292    }
    12661293
    12671294    if (mimeType.isEmpty())
Note: See TracChangeset for help on using the changeset viewer.