Title: [243698] trunk
Revision
243698
Author
[email protected]
Date
2019-04-01 11:21:01 -0700 (Mon, 01 Apr 2019)

Log Message

Add SPI to canonicalize NSURLs with WTF::URL
https://bugs.webkit.org/show_bug.cgi?id=196415
<rdar://problem/44980271>

Patch by Alex Christensen <[email protected]> on 2019-04-01
Reviewed by Darin Adler.

Source/WebKitLegacy/mac:

* Misc/WebNSURLExtras.h:
* Misc/WebNSURLExtras.mm:
(-[NSURL _webkit_canonicalize_with_wtf]):
_webkit_canonicalize is old and changing it causes strange bugs like rdar://problem/5315926
Instead, make a new version that uses WTF::URL to canonicalize an NSURL.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitLegacy/mac/URLCanonicalization.mm: Added.
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (243697 => 243698)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2019-04-01 17:27:53 UTC (rev 243697)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2019-04-01 18:21:01 UTC (rev 243698)
@@ -1,3 +1,17 @@
+2019-04-01  Alex Christensen  <[email protected]>
+
+        Add SPI to canonicalize NSURLs with WTF::URL
+        https://bugs.webkit.org/show_bug.cgi?id=196415
+        <rdar://problem/44980271>
+
+        Reviewed by Darin Adler.
+
+        * Misc/WebNSURLExtras.h:
+        * Misc/WebNSURLExtras.mm:
+        (-[NSURL _webkit_canonicalize_with_wtf]):
+        _webkit_canonicalize is old and changing it causes strange bugs like rdar://problem/5315926
+        Instead, make a new version that uses WTF::URL to canonicalize an NSURL.
+
 2019-03-31  Sam Weinig  <[email protected]>
 
         Remove more i386 specific configurations

Modified: trunk/Source/WebKitLegacy/mac/Misc/WebNSURLExtras.h (243697 => 243698)


--- trunk/Source/WebKitLegacy/mac/Misc/WebNSURLExtras.h	2019-04-01 17:27:53 UTC (rev 243697)
+++ trunk/Source/WebKitLegacy/mac/Misc/WebNSURLExtras.h	2019-04-01 18:21:01 UTC (rev 243698)
@@ -60,6 +60,7 @@
 - (BOOL)_web_isEmpty;
 
 - (NSURL *)_webkit_canonicalize;
+- (NSURL *)_webkit_canonicalize_with_wtf;
 - (NSURL *)_webkit_URLByRemovingFragment;
 - (NSURL *)_web_URLByRemovingUserInfo;
 

Modified: trunk/Source/WebKitLegacy/mac/Misc/WebNSURLExtras.mm (243697 => 243698)


--- trunk/Source/WebKitLegacy/mac/Misc/WebNSURLExtras.mm	2019-04-01 17:27:53 UTC (rev 243697)
+++ trunk/Source/WebKitLegacy/mac/Misc/WebNSURLExtras.mm	2019-04-01 18:21:01 UTC (rev 243698)
@@ -133,6 +133,12 @@
     return URLByCanonicalizingURL(self);
 }
 
+- (NSURL *)_webkit_canonicalize_with_wtf
+{
+    auto url = ""
+    return url.isValid() ? (NSURL *)url : nil;
+}
+
 - (NSURL *)_webkit_URLByRemovingFragment 
 {
     return URLByTruncatingOneCharacterBeforeComponent(self, kCFURLComponentFragment);

Modified: trunk/Tools/ChangeLog (243697 => 243698)


--- trunk/Tools/ChangeLog	2019-04-01 17:27:53 UTC (rev 243697)
+++ trunk/Tools/ChangeLog	2019-04-01 18:21:01 UTC (rev 243698)
@@ -1,3 +1,15 @@
+2019-04-01  Alex Christensen  <[email protected]>
+
+        Add SPI to canonicalize NSURLs with WTF::URL
+        https://bugs.webkit.org/show_bug.cgi?id=196415
+        <rdar://problem/44980271>
+
+        Reviewed by Darin Adler.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitLegacy/mac/URLCanonicalization.mm: Added.
+        (TestWebKitAPI::TEST):
+
 2019-04-01  Zan Dobersek  <[email protected]>
 
         [WPE] EventSenderProxy constructor is called before a PlatformWindow is usable

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (243697 => 243698)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-04-01 17:27:53 UTC (rev 243697)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-04-01 18:21:01 UTC (rev 243698)
@@ -312,6 +312,7 @@
 		5C2936961D5C00ED00DEAB1E /* CookieMessage.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C2936941D5BFD1900DEAB1E /* CookieMessage.html */; };
 		5C4A84951F7EEFFC00ACFC54 /* Configuration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C4A84941F7EEFD400ACFC54 /* Configuration.mm */; };
 		5C69BDD51F82A7EF000F4F4B /* _javascript_DuringNavigation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C69BDD41F82A7EB000F4F4B /* _javascript_DuringNavigation.mm */; };
+		5C6E27A7224EEBEA00128736 /* URLCanonicalization.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C6E27A6224EEBEA00128736 /* URLCanonicalization.mm */; };
 		5C7148952123A40A00FDE3C5 /* WKWebsiteDatastore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C7148942123A40700FDE3C5 /* WKWebsiteDatastore.mm */; };
 		5C75716122124C5200B9E5AC /* BundleRetainPagePlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C75715F221249BD00B9E5AC /* BundleRetainPagePlugIn.mm */; };
 		5C7964101EB0278D0075D74C /* EventModifiers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C79640F1EB0269B0075D74C /* EventModifiers.cpp */; };
@@ -1718,6 +1719,7 @@
 		5C4A84941F7EEFD400ACFC54 /* Configuration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Configuration.mm; sourceTree = "<group>"; };
 		5C5E633D1D0B67940085A025 /* UniqueRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueRef.cpp; sourceTree = "<group>"; };
 		5C69BDD41F82A7EB000F4F4B /* _javascript_DuringNavigation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _javascript_DuringNavigation.mm; sourceTree = "<group>"; };
+		5C6E27A6224EEBEA00128736 /* URLCanonicalization.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = URLCanonicalization.mm; sourceTree = "<group>"; };
 		5C7148942123A40700FDE3C5 /* WKWebsiteDatastore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebsiteDatastore.mm; sourceTree = "<group>"; };
 		5C75715F221249BD00B9E5AC /* BundleRetainPagePlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleRetainPagePlugIn.mm; sourceTree = "<group>"; };
 		5C79640F1EB0269B0075D74C /* EventModifiers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventModifiers.cpp; sourceTree = "<group>"; };
@@ -2850,6 +2852,7 @@
 			children = (
 				9BD5111B1FE8E11600D2B630 /* AccessingPastedImage.mm */,
 				6B306105218A372900F5A802 /* ClosingWebView.mm */,
+				5C6E27A6224EEBEA00128736 /* URLCanonicalization.mm */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -4340,6 +4343,7 @@
 				57152B7821DD4E8D000C37CA /* U2fCommandConstructorTest.cpp in Sources */,
 				5CB40B4E1F4B98D3007DC7B9 /* UIDelegate.mm in Sources */,
 				F46849BE1EEF58E400B937FE /* UIPasteboardTests.mm in Sources */,
+				5C6E27A7224EEBEA00128736 /* URLCanonicalization.mm in Sources */,
 				E3A1E77F21B25B39008C6007 /* URLParserTextEncoding.cpp in Sources */,
 				7CCE7F271A411AF600447C4C /* UserContentController.mm in Sources */,
 				7CCE7F2D1A411B1000447C4C /* UserContentTest.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitLegacy/mac/URLCanonicalization.mm (0 => 243698)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitLegacy/mac/URLCanonicalization.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitLegacy/mac/URLCanonicalization.mm	2019-04-01 18:21:01 UTC (rev 243698)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "Test.h"
+#import <WebKit/WebNSURLExtras.h>
+
+namespace TestWebKitAPI {
+
+TEST(WebKit, URLCanonicalization)
+{
+    NSURL *url = "" URLWithString:@"http://a@/"];
+    EXPECT_NOT_NULL(url);
+    EXPECT_NULL([url _webkit_canonicalize_with_wtf]);
+}
+
+} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to