Title: [125105] branches/safari-536.26-branch/Source/WebCore
Revision
125105
Author
[email protected]
Date
2012-08-08 16:14:58 -0700 (Wed, 08 Aug 2012)

Log Message

Merged r124102.  <rdar://problem/11992689>

Modified Paths

Diff

Modified: branches/safari-536.26-branch/Source/WebCore/ChangeLog (125104 => 125105)


--- branches/safari-536.26-branch/Source/WebCore/ChangeLog	2012-08-08 23:09:37 UTC (rev 125104)
+++ branches/safari-536.26-branch/Source/WebCore/ChangeLog	2012-08-08 23:14:58 UTC (rev 125105)
@@ -1,3 +1,21 @@
+2012-08-07  Lucas Forschler  <[email protected]>
+
+    Merge 124102
+
+    2012-07-30  Anders Carlsson  <[email protected]>
+
+            Crash in logging code if MIME type is null
+            https://bugs.webkit.org/show_bug.cgi?id=92683
+            <rdar://problem/11985295>
+
+            Reviewed by Dan Bernstein.
+
+            If the MIME type is null, try to figure it out from the URL extension. If this fails, return early instead of crashing
+            trying to insert the null string into a hash set.
+
+            * loader/SubframeLoader.cpp:
+            (WebCore::logPluginRequest):
+
 2012-08-08  Lucas Forschler  <[email protected]>
 
     Merge 124720

Modified: branches/safari-536.26-branch/Source/WebCore/loader/SubframeLoader.cpp (125104 => 125105)


--- branches/safari-536.26-branch/Source/WebCore/loader/SubframeLoader.cpp	2012-08-08 23:09:37 UTC (rev 125104)
+++ branches/safari-536.26-branch/Source/WebCore/loader/SubframeLoader.cpp	2012-08-08 23:14:58 UTC (rev 125105)
@@ -134,21 +134,52 @@
     return loadPlugin(ownerElement, url, mimeType, paramNames, paramValues, useFallback);
 }
 
-static void logPluginRequest(Page* page, const String& mimeType, bool success)
+static String findPluginMIMETypeFromURL(Page* page, const String& url)
 {
+    if (!url)
+        return String();
+
+    size_t dotIndex = url.reverseFind('.');
+    if (dotIndex == notFound)
+        return String();
+
+    String extension = url.substring(dotIndex + 1);
+
+    PluginData* pluginData = page->pluginData();
+    for (size_t i = 0; i < pluginData->mimes().size(); ++i) {
+        const MimeClassInfo& mimeClassInfo = pluginData->mimes()[i];
+        for (size_t j = 0; j < mimeClassInfo.extensions.size(); ++j) {
+            if (equalIgnoringCase(extension, mimeClassInfo.extensions[j]))
+                return mimeClassInfo.type;
+        }
+    }
+
+    return String();
+}
+
+static void logPluginRequest(Page* page, const String& mimeType, const String& url, bool success)
+{
     if (!page || !page->settings()->diagnosticLoggingEnabled())
         return;
-    
+
+    String newMIMEType = mimeType;
+    if (!newMIMEType) {
+        // Try to figure out the MIME type from the URL extension.
+        newMIMEType = findPluginMIMETypeFromURL(page, url);
+        if (!newMIMEType)
+            return;
+    }
+
     ChromeClient* client = page->chrome()->client();
-    client->logDiagnosticMessage(success ? DiagnosticLoggingKeys::pluginLoadedKey() : DiagnosticLoggingKeys::pluginLoadingFailedKey(), mimeType, DiagnosticLoggingKeys::noopKey());
+    client->logDiagnosticMessage(success ? DiagnosticLoggingKeys::pluginLoadedKey() : DiagnosticLoggingKeys::pluginLoadingFailedKey(), newMIMEType, DiagnosticLoggingKeys::noopKey());
     
     if (!page->hasSeenAnyPlugin())
         client->logDiagnosticMessage(DiagnosticLoggingKeys::pageContainsAtLeastOnePluginKey(), emptyString(), DiagnosticLoggingKeys::noopKey());
     
-    if (!page->hasSeenPlugin(mimeType))
-        client->logDiagnosticMessage(DiagnosticLoggingKeys::pageContainsPluginKey(), mimeType, DiagnosticLoggingKeys::noopKey());
+    if (!page->hasSeenPlugin(newMIMEType))
+        client->logDiagnosticMessage(DiagnosticLoggingKeys::pageContainsPluginKey(), newMIMEType, DiagnosticLoggingKeys::noopKey());
 
-    page->sawPlugin(mimeType);
+    page->sawPlugin(newMIMEType);
 }
 
 bool SubframeLoader::requestObject(HTMLPlugInImageElement* ownerElement, const String& url, const AtomicString& frameName, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues)
@@ -169,7 +200,7 @@
     bool useFallback;
     if (shouldUsePlugin(completedURL, mimeType, ownerElement->shouldPreferPlugInsForImages(), renderer->hasFallbackContent(), useFallback)) {
         bool success = requestPlugin(ownerElement, completedURL, mimeType, paramNames, paramValues, useFallback);
-        logPluginRequest(document()->page(), mimeType, success);
+        logPluginRequest(document()->page(), mimeType, completedURL, success);
         return success;
     }
 
@@ -253,7 +284,7 @@
     if (allowPlugins(AboutToInstantiatePlugin))
         widget = m_frame->loader()->client()->createJavaAppletWidget(size, element, baseURL, paramNames, paramValues);
 
-    logPluginRequest(document()->page(), element->serviceType(), widget);
+    logPluginRequest(document()->page(), element->serviceType(), String(), widget);
 
     if (!widget) {
         RenderEmbeddedObject* renderer = element->renderEmbeddedObject();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to