Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 0e087dfe1af10698f029462cdb7293fad227b1d5
https://github.com/WebKit/WebKit/commit/0e087dfe1af10698f029462cdb7293fad227b1d5
Author: Ben Nham <[email protected]>
Date: 2026-03-25 (Wed, 25 Mar 2026)
Changed paths:
M LayoutTests/ipc/serialized-type-info.html
M Source/WebKit/Platform/IPC/ArgumentCoders.h
M Source/WebKit/Platform/IPC/TransferString.cpp
M Source/WebKit/Platform/IPC/TransferString.h
M Source/WebKit/Platform/IPC/TransferString.serialization.in
M Source/WebKit/Shared/WTFArgumentCoders.serialization.in
M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
M Tools/TestWebKitAPI/Tests/IPC/TransferStringObjCTests.mm
M Tools/TestWebKitAPI/Tests/IPC/TransferStringTests.cpp
M Tools/TestWebKitAPI/Tests/WebKit/EvaluateJavaScript.cpp
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm
Log Message:
-----------
Fix empty TransferString being deserialized as null string
https://bugs.webkit.org/show_bug.cgi?id=310662
rdar://173272865
Reviewed by Per Arne Vollan.
Sending an empty String instance over IPC via TransferString results in a null
String instance on
the receiver side. This is unexpected and can cause downstream issues. For
instance, if the receiver
then puts the unexpectedly null String in to a hash map, it will crash.
The reason this happens is that TransferString serializes an empty string as an
empty span. On the
receiver side, after IPC, the span is not only empty but contains a null data
member. The null data
member causes the `String(span)` constructor to construct a null String rather
than an empty String.
To fix this, make the `TransferString(IPCData)` constructor always construct
non-null Strings when
it is initialized with a span on the receiver side. Sending and receiving null
strings is already
handled via the existing monostate variant.
Added some tests to make sure empty strings actually deserialize as empty
strings after IPC. This
required some changes so that the serialization logic ended up in
libWebKitPlatform for the API
tests.
This is a reland of 309942@main as that broke builds on some SDKs due to a
missing include of
`<wtf/Variant.h>`.
Tests: Tools/TestWebKitAPI/Tests/IPC/TransferStringObjCTests.mm
Tools/TestWebKitAPI/Tests/IPC/TransferStringTests.cpp
Tools/TestWebKitAPI/Tests/WebKit/EvaluateJavaScript.cpp
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm
* LayoutTests/ipc/serialized-type-info.html:
* Source/WebKit/Platform/IPC/ArgumentCoders.h:
(IPC::ArgumentCoder<std::monostate>::encode):
(IPC::ArgumentCoder<std::monostate>::decode):
* Source/WebKit/Platform/IPC/TransferString.cpp:
* Source/WebKit/Platform/IPC/TransferString.h:
(IPC::TransferString::TransferString):
* Source/WebKit/Platform/IPC/TransferString.serialization.in:
* Source/WebKit/Shared/WTFArgumentCoders.serialization.in:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Tools/TestWebKitAPI/Tests/IPC/TransferStringObjCTests.mm:
(TestWebKitAPI::TEST(TransferStringTests, CreateFromNSString)):
* Tools/TestWebKitAPI/Tests/IPC/TransferStringTests.cpp:
(TestWebKitAPI::TEST(TransferStringTests, CreateFromString)):
* Tools/TestWebKitAPI/Tests/WebKit/EvaluateJavaScript.cpp:
(TestWebKitAPI::didRunEmptyJavaScript):
(TestWebKitAPI::TEST(WebKit, EvaluateEmptyJavaScript)):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm:
(TEST(WKWebView, EvaluateEmptyJavaScript)):
Canonical link: https://commits.webkit.org/309962@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications