- Revision
- 287056
- Author
- [email protected]
- Date
- 2021-12-14 15:48:21 -0800 (Tue, 14 Dec 2021)
Log Message
Remove properties set by NSURLProtocol on NSURLRequest before serializing
https://bugs.webkit.org/show_bug.cgi?id=232332
<rdar://79227845>
Patch by Alex Christensen <[email protected]> on 2021-12-14
Reviewed by Geoff Garen.
Source/WebCore/PAL:
* pal/spi/cf/CFNetworkSPI.h:
Source/WebKit:
NSURLRequest encodeWithCoder: encodes the protocol properties, which are not used by WebKit.
They exist to be used by NSURLProtocol. Serializing them can serialize a large amount of data,
so to be more efficient and hopefully run out of memory less, remove the properties before serializing.
* Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
(IPC::ArgumentCoder<WebCore::ResourceRequest>::encodePlatformData):
Source/WTF:
* wtf/PlatformHave.h:
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm:
(TestWebKitAPI::TEST):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (287055 => 287056)
--- trunk/Source/WTF/ChangeLog 2021-12-14 23:31:41 UTC (rev 287055)
+++ trunk/Source/WTF/ChangeLog 2021-12-14 23:48:21 UTC (rev 287056)
@@ -1,3 +1,13 @@
+2021-12-14 Alex Christensen <[email protected]>
+
+ Remove properties set by NSURLProtocol on NSURLRequest before serializing
+ https://bugs.webkit.org/show_bug.cgi?id=232332
+ <rdar://79227845>
+
+ Reviewed by Geoff Garen.
+
+ * wtf/PlatformHave.h:
+
2021-12-14 Darin Adler <[email protected]>
Automatically generate event handler content attribute maps so they are easier to maintain
Modified: trunk/Source/WTF/wtf/PlatformHave.h (287055 => 287056)
--- trunk/Source/WTF/wtf/PlatformHave.h 2021-12-14 23:31:41 UTC (rev 287055)
+++ trunk/Source/WTF/wtf/PlatformHave.h 2021-12-14 23:48:21 UTC (rev 287056)
@@ -934,6 +934,7 @@
|| (PLATFORM(APPLETV) && __TV_OS_VERSION_MAX_ALLOWED >= 150400) \
|| (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MAX_ALLOWED >= 80400)
#define HAVE_RSA_PSS_OID 1
+#define HAVE_NSURLREQUEST_REMOVE_ALL_PROTOCOL_PROPERTIES 1
#endif
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) \
Modified: trunk/Source/WebCore/PAL/ChangeLog (287055 => 287056)
--- trunk/Source/WebCore/PAL/ChangeLog 2021-12-14 23:31:41 UTC (rev 287055)
+++ trunk/Source/WebCore/PAL/ChangeLog 2021-12-14 23:48:21 UTC (rev 287056)
@@ -1,3 +1,13 @@
+2021-12-14 Alex Christensen <[email protected]>
+
+ Remove properties set by NSURLProtocol on NSURLRequest before serializing
+ https://bugs.webkit.org/show_bug.cgi?id=232332
+ <rdar://79227845>
+
+ Reviewed by Geoff Garen.
+
+ * pal/spi/cf/CFNetworkSPI.h:
+
2021-12-14 Andreu Botella <[email protected]>
TextDecoder doesn't detect invalid UTF-8 sequences early enough
Modified: trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h (287055 => 287056)
--- trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h 2021-12-14 23:31:41 UTC (rev 287055)
+++ trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h 2021-12-14 23:48:21 UTC (rev 287056)
@@ -174,6 +174,9 @@
@end
@interface NSMutableURLRequest ()
+#if HAVE(NSURLREQUEST_REMOVE_ALL_PROTOCOL_PROPERTIES)
+- (void)_removeAllProtocolProperties;
+#endif
- (void)setContentDispositionEncodingFallbackArray:(NSArray *)theEncodingFallbackArray;
- (void)setBoundInterfaceIdentifier:(NSString *)identifier;
- (void)_setPreventHSTSStorage:(BOOL)preventHSTSStorage;
@@ -191,6 +194,9 @@
#endif
@interface NSURLRequest ()
+#if HAVE(NSURLREQUEST_REMOVE_ALL_PROTOCOL_PROPERTIES)
+@property (nonatomic, readonly, nullable, retain) NSDictionary<NSString *, id> *_allProtocolProperties;
+#endif
+ (NSArray *)allowsSpecificHTTPSCertificateForHost:(NSString *)host;
+ (void)setAllowsSpecificHTTPSCertificate:(NSArray *)allow forHost:(NSString *)host;
+ (void)setDefaultTimeoutInterval:(NSTimeInterval)seconds;
Modified: trunk/Source/WebKit/ChangeLog (287055 => 287056)
--- trunk/Source/WebKit/ChangeLog 2021-12-14 23:31:41 UTC (rev 287055)
+++ trunk/Source/WebKit/ChangeLog 2021-12-14 23:48:21 UTC (rev 287056)
@@ -1,3 +1,18 @@
+2021-12-14 Alex Christensen <[email protected]>
+
+ Remove properties set by NSURLProtocol on NSURLRequest before serializing
+ https://bugs.webkit.org/show_bug.cgi?id=232332
+ <rdar://79227845>
+
+ Reviewed by Geoff Garen.
+
+ NSURLRequest encodeWithCoder: encodes the protocol properties, which are not used by WebKit.
+ They exist to be used by NSURLProtocol. Serializing them can serialize a large amount of data,
+ so to be more efficient and hopefully run out of memory less, remove the properties before serializing.
+
+ * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+ (IPC::ArgumentCoder<WebCore::ResourceRequest>::encodePlatformData):
+
2021-12-14 Jer Noble <[email protected]>
Safari intermittently stopping playing Spotify Web Player (currentTime goes backwards)
Modified: trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (287055 => 287056)
--- trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2021-12-14 23:31:41 UTC (rev 287055)
+++ trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2021-12-14 23:48:21 UTC (rev 287056)
@@ -37,6 +37,7 @@
#import <WebCore/FontCustomPlatformData.h>
#import <WebCore/ResourceRequest.h>
#import <WebCore/TextRecognitionResult.h>
+#import <pal/spi/cf/CFNetworkSPI.h>
#import <pal/spi/cf/CoreTextSPI.h>
#if PLATFORM(IOS_FAMILY)
@@ -625,10 +626,20 @@
// We don't send HTTP body over IPC for better performance.
// Also, it's not always possible to do, as streams can only be created in process that does networking.
- if ([requestToSerialize HTTPBody] || [requestToSerialize HTTPBodyStream]) {
+ bool hasHTTPBody = [requestToSerialize HTTPBody] || [requestToSerialize HTTPBodyStream];
+#if HAVE(NSURLREQUEST_REMOVE_ALL_PROTOCOL_PROPERTIES)
+ bool hasProtocolProperties = [requestToSerialize _allProtocolProperties];
+#else
+ bool hasProtocolProperties = false;
+#endif
+
+ if (hasHTTPBody || hasProtocolProperties) {
auto mutableRequest = adoptNS([requestToSerialize mutableCopy]);
[mutableRequest setHTTPBody:nil];
[mutableRequest setHTTPBodyStream:nil];
+#if HAVE(NSURLREQUEST_REMOVE_ALL_PROTOCOL_PROPERTIES)
+ [mutableRequest _removeAllProtocolProperties];
+#endif
requestToSerialize = WTFMove(mutableRequest);
}
Modified: trunk/Tools/ChangeLog (287055 => 287056)
--- trunk/Tools/ChangeLog 2021-12-14 23:31:41 UTC (rev 287055)
+++ trunk/Tools/ChangeLog 2021-12-14 23:48:21 UTC (rev 287056)
@@ -1,3 +1,14 @@
+2021-12-14 Alex Christensen <[email protected]>
+
+ Remove properties set by NSURLProtocol on NSURLRequest before serializing
+ https://bugs.webkit.org/show_bug.cgi?id=232332
+ <rdar://79227845>
+
+ Reviewed by Geoff Garen.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm:
+ (TestWebKitAPI::TEST):
+
2021-12-14 Jonathan Bedard <[email protected]>
[reporelaypy] Update checkout with hook instead of polling (Follow-up fix)
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm (287055 => 287056)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm 2021-12-14 23:31:41 UTC (rev 287055)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm 2021-12-14 23:48:21 UTC (rev 287056)
@@ -137,5 +137,27 @@
[webView _test_waitForDidFinishNavigation];
}
+TEST(WebKit, LoadNSURLRequestWithProtocolProperties)
+{
+ auto request = adoptNS([[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"test:///"]]);
+
+ [NSURLProtocol setProperty:@"world" forKey:@"hello" inRequest:request.get()];
+ auto handler = adoptNS([TestURLSchemeHandler new]);
+ __block bool done = false;
+ handler.get().startURLSchemeTaskHandler = ^(WKWebView *, id<WKURLSchemeTask> task) {
+#if HAVE(NSURLREQUEST_REMOVE_ALL_PROTOCOL_PROPERTIES)
+ EXPECT_FALSE([NSURLProtocol propertyForKey:@"hello" inRequest:task.request]);
+#else
+ EXPECT_TRUE([NSURLProtocol propertyForKey:@"hello" inRequest:task.request]);
+#endif
+ done = true;
+ };
+ auto configuration = adoptNS([WKWebViewConfiguration new]);
+ [configuration setURLSchemeHandler:handler.get() forURLScheme:@"test"];
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSZeroRect configuration:configuration.get()]);
+ [webView loadRequest:request.get()];
+ Util::run(&done);
+}
+
} // namespace TestWebKitAPI