Title: [171993] trunk/Source/WebCore
Revision
171993
Author
psola...@apple.com
Date
2014-08-04 10:19:12 -0700 (Mon, 04 Aug 2014)

Log Message

QuickLook resources are cache-replaced with their original binary data causing ASSERT(m_data->size() == newBuffer->size()) in CachedResource.cpp
https://bugs.webkit.org/show_bug.cgi?id=135548
<rdar://problem/17891321>

Reviewed by David Kilzer.

When loading QuickLook resources, the SharedBuffer in the CachedResource is actually a
converted representation of the real QuickLook resource. Replacing this with the actual
network resource (which is what tryReplaceEncodedData() tried to do) is wrong and triggered
asserts in the code.

Fix this by having CachedRawResource::mayTryReplaceEncodedData() return false if we are
loading a QuickLook resource.

No new tests because we don't have a way to test QuickLook documents.

* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::ResourceLoader):
(WebCore::ResourceLoader::didCreateQuickLookHandle):
    Set a flag to indicate that we are loading a QuickLook document.
* loader/ResourceLoader.h:
(WebCore::ResourceLoader::isQuickLookResource):
* loader/cache/CachedRawResource.cpp:
(WebCore::CachedRawResource::CachedRawResource):
(WebCore::CachedRawResource::finishLoading):
    Check if we were loading a QuickLook document and if so disable encoded data
    replacement.
* loader/cache/CachedRawResource.h:
    Add a new bool field returned by mayTryReplaceEncodedData(). Default is true but it is
    set to false in finishLoading() if we were loading QuickLook document.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (171992 => 171993)


--- trunk/Source/WebCore/ChangeLog	2014-08-04 17:17:30 UTC (rev 171992)
+++ trunk/Source/WebCore/ChangeLog	2014-08-04 17:19:12 UTC (rev 171993)
@@ -1,3 +1,36 @@
+2014-08-04  Pratik Solanki  <psola...@apple.com>
+
+        QuickLook resources are cache-replaced with their original binary data causing ASSERT(m_data->size() == newBuffer->size()) in CachedResource.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=135548
+        <rdar://problem/17891321>
+
+        Reviewed by David Kilzer.
+
+        When loading QuickLook resources, the SharedBuffer in the CachedResource is actually a
+        converted representation of the real QuickLook resource. Replacing this with the actual
+        network resource (which is what tryReplaceEncodedData() tried to do) is wrong and triggered
+        asserts in the code.
+
+        Fix this by having CachedRawResource::mayTryReplaceEncodedData() return false if we are
+        loading a QuickLook resource.
+
+        No new tests because we don't have a way to test QuickLook documents.
+
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::ResourceLoader):
+        (WebCore::ResourceLoader::didCreateQuickLookHandle):
+            Set a flag to indicate that we are loading a QuickLook document.
+        * loader/ResourceLoader.h:
+        (WebCore::ResourceLoader::isQuickLookResource):
+        * loader/cache/CachedRawResource.cpp:
+        (WebCore::CachedRawResource::CachedRawResource):
+        (WebCore::CachedRawResource::finishLoading):
+            Check if we were loading a QuickLook document and if so disable encoded data
+            replacement.
+        * loader/cache/CachedRawResource.h:
+            Add a new bool field returned by mayTryReplaceEncodedData(). Default is true but it is
+            set to false in finishLoading() if we were loading QuickLook document.
+
 2014-08-04  Jer Noble  <jer.no...@apple.com>
 
         [MSE] Seeking occasionally causes many frames to be displayed in "fast forward" mode

Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (171992 => 171993)


--- trunk/Source/WebCore/loader/ResourceLoader.cpp	2014-08-04 17:17:30 UTC (rev 171992)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp	2014-08-04 17:19:12 UTC (rev 171993)
@@ -62,6 +62,7 @@
     , m_cancellationStatus(NotCancelled)
     , m_defersLoading(frame->page()->defersLoading())
     , m_options(options)
+    , m_isQuickLookResource(false)
 {
 }
 
@@ -618,6 +619,7 @@
 #if USE(QUICK_LOOK)
 void ResourceLoader::didCreateQuickLookHandle(QuickLookHandle& handle)
 {
+    m_isQuickLookResource = true;
     frameLoader()->client().didCreateQuickLookHandle(handle);
 }
 #endif

Modified: trunk/Source/WebCore/loader/ResourceLoader.h (171992 => 171993)


--- trunk/Source/WebCore/loader/ResourceLoader.h	2014-08-04 17:17:30 UTC (rev 171992)
+++ trunk/Source/WebCore/loader/ResourceLoader.h	2014-08-04 17:19:12 UTC (rev 171993)
@@ -116,6 +116,7 @@
 #if USE(QUICK_LOOK)
     virtual void didCreateQuickLookHandle(QuickLookHandle&) override;
 #endif
+    bool isQuickLookResource() { return m_isQuickLookResource; }
 
     const URL& url() const { return m_request.url(); }
     ResourceHandle* handle() const { return m_handle.get(); }
@@ -219,6 +220,7 @@
     bool m_defersLoading;
     ResourceRequest m_deferredRequest;
     ResourceLoaderOptions m_options;
+    bool m_isQuickLookResource;
 };
 
 inline const ResourceResponse& ResourceLoader::response() const

Modified: trunk/Source/WebCore/loader/cache/CachedRawResource.cpp (171992 => 171993)


--- trunk/Source/WebCore/loader/cache/CachedRawResource.cpp	2014-08-04 17:17:30 UTC (rev 171992)
+++ trunk/Source/WebCore/loader/cache/CachedRawResource.cpp	2014-08-04 17:19:12 UTC (rev 171993)
@@ -40,6 +40,7 @@
 CachedRawResource::CachedRawResource(ResourceRequest& resourceRequest, Type type, SessionID sessionID)
     : CachedResource(resourceRequest, type, sessionID)
     , m_identifier(0)
+    , m_allowEncodedDataReplacement(true)
 {
     // FIXME: The wrong CachedResource::Type here may cause a bad cast elsewhere.
     ASSERT(isMainOrRawResource());
@@ -95,6 +96,8 @@
         notifyClientsDataWasReceived(incrementalData, incrementalDataLength);
     }
 
+    m_allowEncodedDataReplacement = !m_loader->isQuickLookResource();
+
     CachedResource::finishLoading(data);
     if (dataBufferingPolicy == BufferData && m_options.dataBufferingPolicy() == DoNotBufferData) {
         if (m_loader)

Modified: trunk/Source/WebCore/loader/cache/CachedRawResource.h (171992 => 171993)


--- trunk/Source/WebCore/loader/cache/CachedRawResource.h	2014-08-04 17:17:30 UTC (rev 171992)
+++ trunk/Source/WebCore/loader/cache/CachedRawResource.h	2014-08-04 17:19:12 UTC (rev 171993)
@@ -60,7 +60,7 @@
     virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override;
 
     virtual void switchClientsToRevalidatedResource() override;
-    virtual bool mayTryReplaceEncodedData() const override { return true; }
+    virtual bool mayTryReplaceEncodedData() const override { return m_allowEncodedDataReplacement; }
 
     virtual bool canReuse(const ResourceRequest&) const override;
 
@@ -72,6 +72,7 @@
 #endif
 
     unsigned long m_identifier;
+    bool m_allowEncodedDataReplacement;
 
     struct RedirectPair {
     public:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to