Refactor Ignore HSTS code
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Apr 2018 03:43:46 +0000 (03:43 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Apr 2018 03:43:46 +0000 (03:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184433
<rdar://problem/39298238>

Reviewed by Darin Adler.

This patch refactors our ignore HSTS code. The convenience functions are moved
out of CFNetwork SPI in PAL, and into where they are used. It also switches
from performSelector: calls to straight function calls, after checking that
there is a responder.

Source/WebCore:

* platform/network/mac/WebCoreURLResponse.mm:
(WebCore::schemeWasUpgradedDueToDynamicHSTS):
    Add convenience function here since it was moved out of
    CFNetworkSPI.h.

Source/WebCore/PAL:

* pal/spi/cf/CFNetworkSPI.h:
(schemeWasUpgradedDueToDynamicHSTS): Deleted.
(setIgnoreHSTS): Deleted.
(ignoreHSTS): Deleted.

Source/WebKit:

* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(schemeWasUpgradedDueToDynamicHSTS):
(setIgnoreHSTS):
(ignoreHSTS):
    Add convenience functions here since they were moved out of
    CFNetworkSPI.h.

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

Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h
Source/WebCore/platform/network/mac/WebCoreURLResponse.mm
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm

index c243160..e88699f 100644 (file)
@@ -1,3 +1,21 @@
+2018-04-09  John Wilander  <wilander@apple.com>
+
+        Refactor Ignore HSTS code
+        https://bugs.webkit.org/show_bug.cgi?id=184433
+        <rdar://problem/39298238>
+
+        Reviewed by Darin Adler.
+
+        This patch refactors our ignore HSTS code. The convenience functions are moved
+        out of CFNetwork SPI in PAL, and into where they are used. It also switches
+        from performSelector: calls to straight function calls, after checking that
+        there is a responder.
+
+        * platform/network/mac/WebCoreURLResponse.mm:
+        (WebCore::schemeWasUpgradedDueToDynamicHSTS):
+            Add convenience function here since it was moved out of
+            CFNetworkSPI.h.
+
 2018-04-09  Brady Eidson  <beidson@apple.com>
 
         Expand WebCore policy concept of "shouldContinue" to allow for more than true/false
index ce3479d..fb0c014 100644 (file)
@@ -1,3 +1,21 @@
+2018-04-09  John Wilander  <wilander@apple.com>
+
+        Refactor Ignore HSTS code
+        https://bugs.webkit.org/show_bug.cgi?id=184433
+        <rdar://problem/39298238>
+
+        Reviewed by Darin Adler.
+
+        This patch refactors our ignore HSTS code. The convenience functions are moved
+        out of CFNetwork SPI in PAL, and into where they are used. It also switches
+        from performSelector: calls to straight function calls, after checking that
+        there is a responder.
+
+        * pal/spi/cf/CFNetworkSPI.h:
+        (schemeWasUpgradedDueToDynamicHSTS): Deleted.
+        (setIgnoreHSTS): Deleted.
+        (ignoreHSTS): Deleted.
+
 2018-04-07  Timothy Hatcher  <timothy@apple.com>
 
         Use the system's link color when system appearance is desired for a WebView.
index 151b83c..9ef1caa 100644 (file)
@@ -337,24 +337,4 @@ WTF_EXTERN_C_END
 - (void)_setMIMEType:(NSString *)type;
 @end
 
-static bool schemeWasUpgradedDueToDynamicHSTS(NSURLRequest *request)
-{
-    if ([request respondsToSelector:@selector(_schemeWasUpgradedDueToDynamicHSTS)])
-        return [request performSelector:@selector(_schemeWasUpgradedDueToDynamicHSTS)];
-    return false;
-}
-
-static void setIgnoreHSTS(NSMutableURLRequest *request, bool ignoreHSTS)
-{
-    if ([request respondsToSelector:@selector(_setIgnoreHSTS:)])
-        [request performSelector:@selector(_setIgnoreHSTS:) withObject:[NSNumber numberWithBool:ignoreHSTS]];
-}
-
-static bool ignoreHSTS(NSURLRequest *request)
-{
-    if ([request respondsToSelector:@selector(_ignoreHSTS)])
-        return [request performSelector:@selector(_ignoreHSTS)];
-    return false;
-}
-
 #endif // defined(__OBJC__)
index 71311ff..f265465 100644 (file)
@@ -327,6 +327,17 @@ void adjustMIMETypeIfNecessary(CFURLResponseRef cfResponse, bool isMainResourceL
 }
 #endif
 
+static bool schemeWasUpgradedDueToDynamicHSTS(NSURLRequest *request)
+{
+#if !USE(CFNETWORK_IGNORE_HSTS)
+    UNUSED_PARAM(request);
+    return false;
+#else
+    return [request respondsToSelector:@selector(_schemeWasUpgradedDueToDynamicHSTS)]
+        && [request _schemeWasUpgradedDueToDynamicHSTS];
+#endif
+}
+
 NSURLResponse *synthesizeRedirectResponseIfNecessary(NSURLRequest *currentRequest, NSURLRequest *newRequest, NSURLResponse *redirectResponse)
 {
     if (redirectResponse)
index 94fa098..cd3673f 100644 (file)
@@ -1,3 +1,23 @@
+2018-04-09  John Wilander  <wilander@apple.com>
+
+        Refactor Ignore HSTS code
+        https://bugs.webkit.org/show_bug.cgi?id=184433
+        <rdar://problem/39298238>
+
+        Reviewed by Darin Adler.
+
+        This patch refactors our ignore HSTS code. The convenience functions are moved
+        out of CFNetwork SPI in PAL, and into where they are used. It also switches
+        from performSelector: calls to straight function calls, after checking that
+        there is a responder.
+
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (schemeWasUpgradedDueToDynamicHSTS):
+        (setIgnoreHSTS):
+        (ignoreHSTS):
+            Add convenience functions here since they were moved out of
+            CFNetworkSPI.h.
+
 2018-04-09  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Rename UNUSED to BUNUSED
index f1c9bb8..5fdab69 100644 (file)
@@ -182,6 +182,24 @@ static NSURLRequest* downgradeRequest(NSURLRequest *request)
     ASSERT_NOT_REACHED();
     return request;
 }
+
+static bool schemeWasUpgradedDueToDynamicHSTS(NSURLRequest *request)
+{
+    return [request respondsToSelector:@selector(_schemeWasUpgradedDueToDynamicHSTS)]
+        && [request _schemeWasUpgradedDueToDynamicHSTS];
+}
+
+static void setIgnoreHSTS(NSMutableURLRequest *request, bool ignoreHSTS)
+{
+    if ([request respondsToSelector:@selector(_setIgnoreHSTS:)])
+        [request _setIgnoreHSTS:ignoreHSTS];
+}
+
+static bool ignoreHSTS(NSURLRequest *request)
+{
+    return [request respondsToSelector:@selector(_ignoreHSTS)]
+        && [request _ignoreHSTS];
+}
 #endif
 
 static NSURLRequest* updateIgnoreStrictTransportSecuritySettingIfNecessary(NSURLRequest *request, bool shouldIgnoreHSTS)