Diff
Modified: trunk/LayoutTests/ChangeLog (272008 => 272009)
--- trunk/LayoutTests/ChangeLog 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/LayoutTests/ChangeLog 2021-01-28 12:40:45 UTC (rev 272009)
@@ -1,3 +1,14 @@
+2021-01-28 Carlos Garcia Campos <cgar...@igalia.com>
+
+ Load data URLs in the web process also for synchronous loads
+ https://bugs.webkit.org/show_bug.cgi?id=220981
+
+ Reviewed by Adrian Perez de Castro.
+
+ Remove expectations for tests that are no longer crashing.
+
+ * platform/glib/TestExpectations:
+
2021-01-28 Julian Gonzalez <julian_a_gonza...@apple.com>
Crash from CompositeEditCommand::moveParagraphs() using Position instead of VisiblePosition
Modified: trunk/LayoutTests/platform/glib/TestExpectations (272008 => 272009)
--- trunk/LayoutTests/platform/glib/TestExpectations 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/LayoutTests/platform/glib/TestExpectations 2021-01-28 12:40:45 UTC (rev 272009)
@@ -723,16 +723,6 @@
webkit.org/b/217267 http/wpt/service-workers/service-worker-spinning-install.https.html [ Pass Failure ]
webkit.org/b/217267 http/wpt/service-workers/service-worker-spinning-message.https.html [ Pass Failure ]
-# Start of r271879 regressions (SoupeMessage changes for libsoup3)
-webkit.org/b/221023 fast/encoding/char-decoding-mac.html [ Crash ]
-webkit.org/b/221023 fast/encoding/char-decoding.html [ Crash ]
-webkit.org/b/221023 svg/load-event-detached.html [ Crash ]
-webkit.org/b/221023 fast/events/event-handler-detached-document.html [ Crash ]
-webkit.org/b/221023 imported/w3c/web-platform-tests/xhr/xmlhttprequest-sync-block-defer-scripts.html [ Crash ]
-webkit.org/b/221023 imported/w3c/web-platform-tests/xhr/xmlhttprequest-sync-block-scripts.html [ Crash ]
-webkit.org/b/221023 imported/w3c/web-platform-tests/xhr/xmlhttprequest-sync-default-feature-policy.sub.html [ Crash ]
-webkit.org/b/221023 imported/w3c/web-platform-tests/xhr/xmlhttprequest-sync-not-hang-scriptloader.html [ Crash ]
-
#////////////////////////////////////////////////////////////////////////////////////////
# End of SOUP and Networking-related bugs
#////////////////////////////////////////////////////////////////////////////////////////
Modified: trunk/Source/WebCore/ChangeLog (272008 => 272009)
--- trunk/Source/WebCore/ChangeLog 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebCore/ChangeLog 2021-01-28 12:40:45 UTC (rev 272009)
@@ -1,3 +1,31 @@
+2021-01-28 Carlos Garcia Campos <cgar...@igalia.com>
+
+ Load data URLs in the web process also for synchronous loads
+ https://bugs.webkit.org/show_bug.cgi?id=220981
+
+ Reviewed by Adrian Perez de Castro.
+
+ Add synchronous API for DataURLDecoder. It now uses a Vector<char> for the data instead of SharedBuffer. That
+ way, ResourceLoader can create the SharedBuffer from the given data and loader strategy can simply move it.
+
+ * Headers.cmake: Add DataURLDecoder.h.
+ * WebCore.xcodeproj/project.pbxproj: Mark DataURLDecoder.h as private.
+ * loader/ResourceLoader.cpp:
+ (WebCore::ResourceLoader::loadDataURL): Adapt to the DataURLDecoder API changes.
+ * platform/network/DataURLDecoder.cpp:
+ (WebCore::DataURLDecoder::parseMediaType): Update the data initialization.
+ (WebCore::DataURLDecoder::decodeBase64): Return bool to indicate success or error and move the resulting vector
+ instead of creating a SharedBuffer.
+ (WebCore::DataURLDecoder::decodeEscaped): Move the resulting vector instead of creating a SharedBuffer.
+ (WebCore::DataURLDecoder::decodeSynchronously): Helper to do the actual decoding synchronously.
+ (WebCore::DataURLDecoder::decode): Use decodeSynchronously.
+ (WebCore::DataURLDecoder::decode): Synchronous implementation.
+ * platform/network/DataURLDecoder.h:
+ * platform/network/ResourceResponseBase.cpp:
+ (WebCore::ResourceResponseBase::dataURLResponse): Create a ResourceResponse for the given url and DataURLDecoder::Result.
+ * platform/text/DecodeEscapeSequences.h:
+ (WebCore::decodeURLEscapeSequencesAsData): Use Vector<char> so that we can avoid data copies.
+
2021-01-28 Julian Gonzalez <julian_a_gonza...@apple.com>
Crash from CompositeEditCommand::moveParagraphs() using Position instead of VisiblePosition
Modified: trunk/Source/WebCore/Headers.cmake (272008 => 272009)
--- trunk/Source/WebCore/Headers.cmake 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebCore/Headers.cmake 2021-01-28 12:40:45 UTC (rev 272009)
@@ -1391,6 +1391,7 @@
platform/network/CredentialStorage.h
platform/network/DNS.h
platform/network/DNSResolveQueue.h
+ platform/network/DataURLDecoder.h
platform/network/FormData.h
platform/network/HTTPCookieAcceptPolicy.h
platform/network/HTTPHeaderMap.h
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (272008 => 272009)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-01-28 12:40:45 UTC (rev 272009)
@@ -983,7 +983,7 @@
371F53E90D2704F900ECE0D5 /* CSSUnicodeRangeValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 371F53E70D2704F900ECE0D5 /* CSSUnicodeRangeValue.h */; };
372ADA38197F47B900FC501E /* ProtectionSpaceCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 372ADA37197F47B900FC501E /* ProtectionSpaceCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
372C00D9129619F8005C9575 /* FindOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 372C00D8129619F8005C9575 /* FindOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 372D3E54216578AE00C5E021 /* DataURLDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A007821B820EC8002C5A6E /* DataURLDecoder.h */; };
+ 372D3E54216578AE00C5E021 /* DataURLDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A007821B820EC8002C5A6E /* DataURLDecoder.h */; settings = {ATTRIBUTES = (Private, ); }; };
372D3E55216578AE00C5E021 /* ScriptModuleLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */; };
372D3E57216578AE00C5E021 /* NavigatorCredentials.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D846261FE895F800CA3682 /* NavigatorCredentials.h */; };
375CD232119D43C800A2A859 /* Hyphenation.h in Headers */ = {isa = PBXBuildFile; fileRef = 375CD231119D43C800A2A859 /* Hyphenation.h */; };
Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (272008 => 272009)
--- trunk/Source/WebCore/loader/ResourceLoader.cpp 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp 2021-01-28 12:40:45 UTC (rev 272009)
@@ -271,15 +271,10 @@
}
if (this->wasCancelled())
return;
- auto& result = decodeResult.value();
- auto dataSize = result.data ? result.data->size() : 0;
- ResourceResponse dataResponse { url, result.mimeType, static_cast<long long>(dataSize), result.charset };
- dataResponse.setHTTPStatusCode(200);
- dataResponse.setHTTPStatusText("OK"_s);
- dataResponse.setHTTPHeaderField(HTTPHeaderName::ContentType, result.contentType);
- dataResponse.setSource(ResourceResponse::Source::Network);
- this->didReceiveResponse(dataResponse, [this, protectedThis = WTFMove(protectedThis), dataSize, data = "" mutable {
+ auto dataSize = decodeResult->data.size();
+ ResourceResponse dataResponse = ResourceResponse::dataURLResponse(url, decodeResult.value());
+ this->didReceiveResponse(dataResponse, [this, protectedThis = WTFMove(protectedThis), dataSize, data = "" mutable {
if (!this->reachedTerminalState() && dataSize && m_request.httpMethod() != "HEAD")
this->didReceiveBuffer(WTFMove(data), dataSize, DataPayloadWholeResource);
Modified: trunk/Source/WebCore/platform/network/DataURLDecoder.cpp (272008 => 272009)
--- trunk/Source/WebCore/platform/network/DataURLDecoder.cpp 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebCore/platform/network/DataURLDecoder.cpp 2021-01-28 12:40:45 UTC (rev 272009)
@@ -29,7 +29,6 @@
#include "DecodeEscapeSequences.h"
#include "HTTPParsers.h"
#include "ParsedContentType.h"
-#include "SharedBuffer.h"
#include "TextEncoding.h"
#include <wtf/MainThread.h>
#include <wtf/Optional.h>
@@ -71,8 +70,8 @@
static Result parseMediaType(const String& mediaType)
{
if (Optional<ParsedContentType> parsedContentType = ParsedContentType::create(mediaType))
- return { parsedContentType->mimeType(), parsedContentType->charset(), parsedContentType->serialize(), nullptr };
- return { "text/plain"_s, "US-ASCII"_s, "text/plain;charset=US-ASCII"_s, nullptr };
+ return { parsedContentType->mimeType(), parsedContentType->charset(), parsedContentType->serialize(), { } };
+ return { "text/plain"_s, "US-ASCII"_s, "text/plain;charset=US-ASCII"_s, { } };
}
struct DecodeTask {
@@ -135,7 +134,7 @@
StringView encodedData;
bool isBase64 { false };
const ScheduleContext scheduleContext;
- const DecodeCompletionHandler completionHandler;
+ DecodeCompletionHandler completionHandler;
Result result;
};
@@ -149,13 +148,13 @@
);
}
-static void decodeBase64(DecodeTask& task, Mode mode)
+static bool decodeBase64(DecodeTask& task, Mode mode)
{
Vector<char> buffer;
if (mode == Mode::ForgivingBase64) {
auto unescapedString = decodeURLEscapeSequences(task.encodedData.toStringWithoutCopying());
if (!base64Decode(unescapedString, buffer, Base64ValidatePadding | Base64IgnoreSpacesAndNewLines | Base64DiscardVerticalTab))
- return;
+ return false;
} else {
// First try base64url.
if (!base64URLDecode(task.encodedData.toStringWithoutCopying(), buffer)) {
@@ -162,11 +161,13 @@
// Didn't work, try unescaping and decoding as base64.
auto unescapedString = decodeURLEscapeSequences(task.encodedData.toStringWithoutCopying());
if (!base64Decode(unescapedString, buffer, Base64IgnoreSpacesAndNewLines | Base64DiscardVerticalTab))
- return;
+ return false;
}
}
buffer.shrinkToFit();
- task.result.data = ""
+ task.result.data = ""
+
+ return true;
}
static void decodeEscaped(DecodeTask& task)
@@ -176,31 +177,36 @@
auto buffer = decodeURLEscapeSequencesAsData(task.encodedData, encoding);
buffer.shrinkToFit();
- task.result.data = ""
+ task.result.data = ""
}
+static Optional<Result> decodeSynchronously(DecodeTask& task, Mode mode)
+{
+ if (!task.process())
+ return WTF::nullopt;
+
+ if (task.isBase64) {
+ if (!decodeBase64(task, mode))
+ return WTF::nullopt;
+ } else
+ decodeEscaped(task);
+
+ return WTFMove(task.result);
+}
+
void decode(const URL& url, const ScheduleContext& scheduleContext, Mode mode, DecodeCompletionHandler&& completionHandler)
{
ASSERT(url.protocolIsData());
decodeQueue().dispatch([decodeTask = createDecodeTask(url, scheduleContext, WTFMove(completionHandler)), mode]() mutable {
- if (decodeTask->process()) {
- if (decodeTask->isBase64)
- decodeBase64(*decodeTask, mode);
- else
- decodeEscaped(*decodeTask);
- }
+ auto result = decodeSynchronously(*decodeTask, mode);
#if USE(COCOA_EVENT_LOOP)
auto scheduledPairs = decodeTask->scheduleContext.scheduledPairs;
#endif
- auto callCompletionHandler = [decodeTask = WTFMove(decodeTask)] {
- if (!decodeTask->result.data) {
- decodeTask->completionHandler({ });
- return;
- }
- decodeTask->completionHandler(WTFMove(decodeTask->result));
+ auto callCompletionHandler = [result = WTFMove(result), completionHandler = WTFMove(decodeTask->completionHandler)]() mutable {
+ completionHandler(WTFMove(result));
};
#if USE(COCOA_EVENT_LOOP)
@@ -211,5 +217,13 @@
});
}
+Optional<Result> decode(const URL& url, Mode mode)
+{
+ ASSERT(url.protocolIsData());
+
+ auto task = createDecodeTask(url, { }, nullptr);
+ return decodeSynchronously(*task, mode);
}
-}
+
+} // namespace DataURLDecoder
+} // namespace WebCore
Modified: trunk/Source/WebCore/platform/network/DataURLDecoder.h (272008 => 272009)
--- trunk/Source/WebCore/platform/network/DataURLDecoder.h 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebCore/platform/network/DataURLDecoder.h 2021-01-28 12:40:45 UTC (rev 272009)
@@ -41,7 +41,7 @@
String mimeType;
String charset;
String contentType;
- RefPtr<SharedBuffer> data;
+ Vector<char> data;
};
using DecodeCompletionHandler = WTF::Function<void (Optional<Result>)>;
@@ -53,6 +53,7 @@
enum class Mode { Legacy, ForgivingBase64 };
void decode(const URL&, const ScheduleContext&, Mode, DecodeCompletionHandler&&);
+WEBCORE_EXPORT Optional<Result> decode(const URL&, Mode);
}
Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp (272008 => 272009)
--- trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp 2021-01-28 12:40:45 UTC (rev 272009)
@@ -28,6 +28,7 @@
#include "ResourceResponseBase.h"
#include "CacheValidation.h"
+#include "DataURLDecoder.h"
#include "HTTPHeaderNames.h"
#include "HTTPParsers.h"
#include "MIMETypeRegistry.h"
@@ -148,6 +149,17 @@
return redirectResponse;
}
+ResourceResponse ResourceResponseBase::dataURLResponse(const URL& url, const DataURLDecoder::Result& result)
+{
+ ResourceResponse dataResponse { url, result.mimeType, static_cast<long long>(result.data.size()), result.charset };
+ dataResponse.setHTTPStatusCode(200);
+ dataResponse.setHTTPStatusText("OK"_s);
+ dataResponse.setHTTPHeaderField(HTTPHeaderName::ContentType, result.contentType);
+ dataResponse.setSource(ResourceResponse::Source::Network);
+
+ return dataResponse;
+}
+
ResourceResponse ResourceResponseBase::filter(const ResourceResponse& response, PerformExposeAllHeadersCheck performCheck)
{
if (response.tainting() == Tainting::Opaque) {
Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.h (272008 => 272009)
--- trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2021-01-28 12:40:45 UTC (rev 272009)
@@ -39,6 +39,10 @@
namespace WebCore {
+namespace DataURLDecoder {
+struct Result;
+}
+
class ResourceResponse;
bool isScriptAllowedByNosniff(const ResourceResponse&);
@@ -211,6 +215,8 @@
bool containsInvalidHTTPHeaders() const;
+ WEBCORE_EXPORT static ResourceResponse dataURLResponse(const URL&, const DataURLDecoder::Result&);
+
protected:
enum InitLevel {
Uninitialized,
Modified: trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h (272008 => 272009)
--- trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h 2021-01-28 12:40:45 UTC (rev 272009)
@@ -154,11 +154,11 @@
return result.toString();
}
-inline Vector<uint8_t> decodeURLEscapeSequencesAsData(StringView string, const TextEncoding& encoding)
+inline Vector<char> decodeURLEscapeSequencesAsData(StringView string, const TextEncoding& encoding)
{
ASSERT(encoding.isValid());
- Vector<uint8_t> result;
+ Vector<char> result;
size_t decodedPosition = 0;
size_t searchPosition = 0;
while (true) {
Modified: trunk/Source/WebKit/ChangeLog (272008 => 272009)
--- trunk/Source/WebKit/ChangeLog 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebKit/ChangeLog 2021-01-28 12:40:45 UTC (rev 272009)
@@ -1,3 +1,20 @@
+2021-01-28 Carlos Garcia Campos <cgar...@igalia.com>
+
+ Load data URLs in the web process also for synchronous loads
+ https://bugs.webkit.org/show_bug.cgi?id=220981
+
+ Reviewed by Adrian Perez de Castro.
+
+ In r271879 I removed the support for data URLs in the network process for soup, assuming data URLs were always
+ loaded from the web process, but that's not the case for synchronous loads.
+
+ * NetworkProcess/soup/NetworkDataTaskSoup.cpp:
+ (WebKit::NetworkDataTaskSoup::createRequest): Schedule an error if URL is not file or HTTP family.
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::WebLoaderStrategy::loadDataURLSynchronously): Helper to load a Data URL synchronously.
+ (WebKit::WebLoaderStrategy::loadResourceSynchronously): Call loadDataURLSynchronously for data URLs.
+ * WebProcess/Network/WebLoaderStrategy.h:
+
2021-01-27 Devin Rousso <drou...@apple.com>
[iOS] add accessibility image extraction contextmenu item for revealing images
Modified: trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp (272008 => 272009)
--- trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp 2021-01-28 12:40:45 UTC (rev 272009)
@@ -113,6 +113,11 @@
return;
}
+ if (!m_currentRequest.url().protocolIsInHTTPFamily()) {
+ scheduleFailure(InvalidURLFailure);
+ return;
+ }
+
GUniquePtr<SoupURI> soupURI = m_currentRequest.createSoupURI();
if (!soupURI) {
scheduleFailure(InvalidURLFailure);
Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (272008 => 272009)
--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2021-01-28 12:40:45 UTC (rev 272009)
@@ -48,6 +48,7 @@
#include <WebCore/ApplicationCacheHost.h>
#include <WebCore/CachedResource.h>
#include <WebCore/ContentSecurityPolicy.h>
+#include <WebCore/DataURLDecoder.h>
#include <WebCore/DiagnosticLoggingClient.h>
#include <WebCore/DiagnosticLoggingKeys.h>
#include <WebCore/Document.h>
@@ -527,6 +528,26 @@
return true;
}
+WebLoaderStrategy::SyncLoadResult WebLoaderStrategy::loadDataURLSynchronously(const ResourceRequest& request)
+{
+ auto mode = DataURLDecoder::Mode::Legacy;
+ if (request.requester() == ResourceRequest::Requester::Fetch)
+ mode = DataURLDecoder::Mode::ForgivingBase64;
+
+ SyncLoadResult result;
+ auto decodeResult = DataURLDecoder::decode(request.url(), mode);
+ if (!decodeResult) {
+ RELEASE_LOG_IF_ALLOWED("loadDataURLSynchronously: decoding of data failed");
+ result.error = internalError(request.url());
+ return result;
+ }
+
+ result.response = ResourceResponse::dataURLResponse(request.url(), decodeResult.value());
+ result.data = ""
+
+ return result;
+}
+
Optional<WebLoaderStrategy::SyncLoadResult> WebLoaderStrategy::tryLoadingSynchronouslyUsingURLSchemeHandler(FrameLoader& frameLoader, ResourceLoadIdentifier identifier, const ResourceRequest& request)
{
auto* webFrameLoaderClient = toWebFrameLoaderClient(frameLoader.client());
@@ -570,6 +591,15 @@
return;
}
+ if (request.url().protocolIsData()) {
+ WEBLOADERSTRATEGY_WITH_FRAMELOADER_RELEASE_LOG_ERROR_IF_ALLOWED("loadResourceSynchronously: URL will be loaded as data");
+ auto syncLoadResult = loadDataURLSynchronously(request);
+ error = WTFMove(syncLoadResult.error);
+ response = WTFMove(syncLoadResult.response);
+ data = ""
+ return;
+ }
+
if (auto syncLoadResult = tryLoadingSynchronouslyUsingURLSchemeHandler(frameLoader, resourceLoadIdentifier, request)) {
WEBLOADERSTRATEGY_WITH_FRAMELOADER_RELEASE_LOG_ERROR_IF_ALLOWED("loadResourceSynchronously: failed calling tryLoadingSynchronouslyUsingURLSchemeHandler (error=%d)", syncLoadResult->error.errorCode());
error = WTFMove(syncLoadResult->error);
Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h (272008 => 272009)
--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h 2021-01-28 10:58:23 UTC (rev 272008)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h 2021-01-28 12:40:45 UTC (rev 272009)
@@ -104,6 +104,7 @@
Vector<char> data;
};
Optional<SyncLoadResult> tryLoadingSynchronouslyUsingURLSchemeHandler(WebCore::FrameLoader&, ResourceLoadIdentifier, const WebCore::ResourceRequest&);
+ SyncLoadResult loadDataURLSynchronously(const WebCore::ResourceRequest&);
WebCore::ResourceResponse responseFromResourceLoadIdentifier(uint64_t resourceLoadIdentifier) final;
Vector<WebCore::NetworkTransactionInformation> intermediateLoadInformationFromResourceLoadIdentifier(uint64_t resourceLoadIdentifier) final;