Changeset 270998 in webkit


Ignore:
Timestamp:
Dec 18, 2020 5:02:47 PM (19 months ago)
Author:
beidson@apple.com
Message:

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.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r270997 r270998  
     12020-12-18  Brady Eidson  <beidson@apple.com>
     2
     3        Fix some issues with PDFs as <object>.
     4        https://bugs.webkit.org/show_bug.cgi?id=220024
     5
     6        Reviewed by Tim Horton.
     7
     8        No new tests (Unable to write automated tests)
     9
     10        * WebProcess/Plugins/PDF/PDFPlugin.mm:
     11        (WebKit::dataProviderGetBytesAtPositionCallback):
     12        (WebKit::PDFPlugin::getResourceBytesAtPosition): Set the correct URL.
     13        (WebKit::PDFPlugin::ByteRangeRequest::completeWithAccumulatedData): Try harder to catch mismatches in delivered bytes vs expected bytes.
     14
    1152020-12-18  Jeff Miller  <jeffm@apple.com>
    216
  • trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm

    r270946 r270998  
    786786    RunLoop::main().dispatch([plugin = WTFMove(plugin), position, count, buffer, &dataSemaphore, &bytesProvided] {
    787787        plugin->getResourceBytesAtPosition(count, position, [count, buffer, &dataSemaphore, &bytesProvided](const uint8_t* bytes, size_t bytesCount) {
    788             ASSERT_UNUSED(count, bytesCount <= count);
     788            RELEASE_ASSERT(bytesCount <= count);
    789789            memcpy(buffer, bytes, bytesCount);
    790790            bytesProvided = bytesCount;
     
    975975
    976976    auto resourceRequest = documentLoader->request();
     977    resourceRequest.setURL(m_sourceURL);
    977978    resourceRequest.setHTTPHeaderField(HTTPHeaderName::Range, makeString("bytes="_s, position, "-"_s, position + count - 1));
    978979    resourceRequest.setCachePolicy(ResourceRequestCachePolicy::DoNotUseAnyCache);
     
    10551056#endif
    10561057
    1057     m_completionHandler(m_accumulatedData.data(), m_accumulatedData.size());
     1058    auto completionSize = m_accumulatedData.size();
     1059    if (completionSize > m_count) {
     1060        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.");
     1061        completionSize = m_count;
     1062    }
     1063
     1064    m_completionHandler(m_accumulatedData.data(), completionSize);
    10581065
    10591066    // Fold this data into the main data buffer so that if something in its range is requested again (which happens quite often)
Note: See TracChangeset for help on using the changeset viewer.