Title: [271029] branches/safari-610-branch/Source/WebKit
Revision
271029
Author
[email protected]
Date
2020-12-21 10:48:28 -0800 (Mon, 21 Dec 2020)

Log Message

Cherry-pick r270998. rdar://problem/72552852

    Fix some issues with PDFs as <object>.
    https://bugs.webkit.org/show_bug.cgi?id=220024

    Reviewed by Tim Horton.

    No new tests (Unable to write automated tests)

    * WebProcess/Plugins/PDF/PDFPlugin.mm:
    (WebKit::dataProviderGetBytesAtPositionCallback):
    (WebKit::PDFPlugin::getResourceBytesAtPosition): Set the correct URL.
    (WebKit::PDFPlugin::ByteRangeRequest::completeWithAccumulatedData): Try harder to catch mismatches in delivered bytes vs expected bytes.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270998 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-610-branch/Source/WebKit/ChangeLog (271028 => 271029)


--- branches/safari-610-branch/Source/WebKit/ChangeLog	2020-12-21 18:48:10 UTC (rev 271028)
+++ branches/safari-610-branch/Source/WebKit/ChangeLog	2020-12-21 18:48:28 UTC (rev 271029)
@@ -1,3 +1,36 @@
+2020-12-21  Alan Coon  <[email protected]>
+
+        Cherry-pick r270998. rdar://problem/72552852
+
+    Fix some issues with PDFs as <object>.
+    https://bugs.webkit.org/show_bug.cgi?id=220024
+    
+    Reviewed by Tim Horton.
+    
+    No new tests (Unable to write automated tests)
+    
+    * WebProcess/Plugins/PDF/PDFPlugin.mm:
+    (WebKit::dataProviderGetBytesAtPositionCallback):
+    (WebKit::PDFPlugin::getResourceBytesAtPosition): Set the correct URL.
+    (WebKit::PDFPlugin::ByteRangeRequest::completeWithAccumulatedData): Try harder to catch mismatches in delivered bytes vs expected bytes.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270998 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-12-18  Brady Eidson  <[email protected]>
+
+            Fix some issues with PDFs as <object>.
+            https://bugs.webkit.org/show_bug.cgi?id=220024
+
+            Reviewed by Tim Horton.
+
+            No new tests (Unable to write automated tests)
+
+            * WebProcess/Plugins/PDF/PDFPlugin.mm:
+            (WebKit::dataProviderGetBytesAtPositionCallback):
+            (WebKit::PDFPlugin::getResourceBytesAtPosition): Set the correct URL.
+            (WebKit::PDFPlugin::ByteRangeRequest::completeWithAccumulatedData): Try harder to catch mismatches in delivered bytes vs expected bytes.
+
 2020-12-15  Alan Coon  <[email protected]>
 
         Cherry-pick r270559. rdar://problem/72320712

Modified: branches/safari-610-branch/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm (271028 => 271029)


--- branches/safari-610-branch/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm	2020-12-21 18:48:10 UTC (rev 271028)
+++ branches/safari-610-branch/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm	2020-12-21 18:48:28 UTC (rev 271029)
@@ -772,7 +772,7 @@
 
     RunLoop::main().dispatch([plugin = WTFMove(plugin), position, count, buffer, &dataSemaphore, &bytesProvided] {
         plugin->getResourceBytesAtPosition(count, position, [count, buffer, &dataSemaphore, &bytesProvided](const uint8_t* bytes, size_t bytesCount) {
-            ASSERT_UNUSED(count, bytesCount <= count);
+            RELEASE_ASSERT(bytesCount <= count);
             memcpy(buffer, bytes, bytesCount);
             bytesProvided = bytesCount;
             dataSemaphore.signal();
@@ -959,6 +959,7 @@
         return;
 
     auto resourceRequest = documentLoader->request();
+    resourceRequest.setURL(m_sourceURL);
     resourceRequest.setHTTPHeaderField(HTTPHeaderName::Range, makeString("bytes="_s, position, "-"_s, position + count - 1));
     resourceRequest.setCachePolicy(ResourceRequestCachePolicy::DoNotUseAnyCache);
 
@@ -1039,8 +1040,14 @@
     plugin.pdfLog(makeString("Completing range request ", identifier()," (", m_count," bytes at ", m_position,") with ", m_accumulatedData.size()," bytes from the network"));
 #endif
 
-    m_completionHandler(m_accumulatedData.data(), m_accumulatedData.size());
+    auto completionSize = m_accumulatedData.size();
+    if (completionSize > m_count) {
+        RELEASE_LOG_ERROR(IncrementalPDF, "PDF byte range request got more bytes back from the server than requested. This is likely due to a misconfigured server. Capping result at the requested number of bytes.");
+        completionSize = m_count;
+    }
 
+    m_completionHandler(m_accumulatedData.data(), completionSize);
+
     // Fold this data into the main data buffer so that if something in its range is requested again (which happens quite often)
     // we do not need to hit the network layer again.
     plugin.ensureDataBufferLength(m_position + m_accumulatedData.size());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to