- Revision
- 264382
- Author
- commit-qu...@webkit.org
- Date
- 2020-07-14 16:36:58 -0700 (Tue, 14 Jul 2020)
Log Message
REGRESSION(r262341) URL::createCFURL should produce a CFURL that uses UTF-8 to decode its percent-encoded sequences
https://bugs.webkit.org/show_bug.cgi?id=214314
<rdar://problem/65079249>
Patch by Alex Christensen <achristen...@webkit.org> on 2020-07-14
Reviewed by Darin Adler.
Source/WTF:
r262341 made it so we usually pass kCFStringEncodingISOLatin1 into CFURLCreateAbsoluteURLWithBytes when creating a CFURLRef from a WTF::URL.
This is correct for the interpretation of the bytes to create a CFStringRef, and that is a change we want to make.
The encoding, however, is also stored with the CFURL and used later when interpreting percent-encoded sequences.
We want to use kCFStringEncodingUTF8 to make the interpretation of percent-encoded sequences the same as it used to be.
To avoid making a separate CString most of the time, use characters8() only for ASCII-only URLs, where UTF-8 and Latin1 are the same.
For all other URLs, we have to make a CString containing the UTF-8 representation of the string to get the percent-encoded sequences interpreted the same.
* wtf/cf/URLCF.cpp:
(WTF::URL::createCFURL const):
* wtf/cocoa/URLCocoa.mm:
(WTF::URL::createCFURL const):
Tools:
* TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm:
Add a direct test and update the Mojave test expectations for the test introduced in r262341 with the change that introduced this regression.
* TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm:
Update a test from r263475 which fixed another regression from r262341.
The test verified that nothing crashed or timed out, and that is still the case even with this intentional change in behavior.
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (264381 => 264382)
--- trunk/Source/WTF/ChangeLog 2020-07-14 23:10:11 UTC (rev 264381)
+++ trunk/Source/WTF/ChangeLog 2020-07-14 23:36:58 UTC (rev 264382)
@@ -1,3 +1,23 @@
+2020-07-14 Alex Christensen <achristen...@webkit.org>
+
+ REGRESSION(r262341) URL::createCFURL should produce a CFURL that uses UTF-8 to decode its percent-encoded sequences
+ https://bugs.webkit.org/show_bug.cgi?id=214314
+ <rdar://problem/65079249>
+
+ Reviewed by Darin Adler.
+
+ r262341 made it so we usually pass kCFStringEncodingISOLatin1 into CFURLCreateAbsoluteURLWithBytes when creating a CFURLRef from a WTF::URL.
+ This is correct for the interpretation of the bytes to create a CFStringRef, and that is a change we want to make.
+ The encoding, however, is also stored with the CFURL and used later when interpreting percent-encoded sequences.
+ We want to use kCFStringEncodingUTF8 to make the interpretation of percent-encoded sequences the same as it used to be.
+ To avoid making a separate CString most of the time, use characters8() only for ASCII-only URLs, where UTF-8 and Latin1 are the same.
+ For all other URLs, we have to make a CString containing the UTF-8 representation of the string to get the percent-encoded sequences interpreted the same.
+
+ * wtf/cf/URLCF.cpp:
+ (WTF::URL::createCFURL const):
+ * wtf/cocoa/URLCocoa.mm:
+ (WTF::URL::createCFURL const):
+
2020-07-14 Jer Noble <jer.no...@apple.com>
Add support for parsing VP-style codec strings.
Modified: trunk/Source/WTF/wtf/cf/URLCF.cpp (264381 => 264382)
--- trunk/Source/WTF/wtf/cf/URLCF.cpp 2020-07-14 23:10:11 UTC (rev 264381)
+++ trunk/Source/WTF/wtf/cf/URLCF.cpp 2020-07-14 23:36:58 UTC (rev 264382)
@@ -51,8 +51,8 @@
RetainPtr<CFURLRef> URL::createCFURL() const
{
RetainPtr<CFURLRef> cfURL;
- if (LIKELY(m_string.is8Bit()))
- cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(m_string.characters8()), m_string.length(), kCFStringEncodingISOLatin1, nullptr, true));
+ if (LIKELY(m_string.is8Bit() && m_string.isAllASCII()))
+ cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(m_string.characters8()), m_string.length(), kCFStringEncodingUTF8, nullptr, true));
else {
CString utf8 = m_string.utf8();
cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(utf8.data()), utf8.length(), kCFStringEncodingUTF8, nullptr, true));
Modified: trunk/Source/WTF/wtf/cocoa/URLCocoa.mm (264381 => 264382)
--- trunk/Source/WTF/wtf/cocoa/URLCocoa.mm 2020-07-14 23:10:11 UTC (rev 264381)
+++ trunk/Source/WTF/wtf/cocoa/URLCocoa.mm 2020-07-14 23:36:58 UTC (rev 264382)
@@ -69,8 +69,8 @@
}
RetainPtr<CFURLRef> cfURL;
- if (LIKELY(m_string.is8Bit()))
- cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(m_string.characters8()), m_string.length(), kCFStringEncodingISOLatin1, nullptr, true));
+ if (LIKELY(m_string.is8Bit() && m_string.isAllASCII()))
+ cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(m_string.characters8()), m_string.length(), kCFStringEncodingUTF8, nullptr, true));
else {
CString utf8 = m_string.utf8();
cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(utf8.data()), utf8.length(), kCFStringEncodingUTF8, nullptr, true));
Modified: trunk/Tools/ChangeLog (264381 => 264382)
--- trunk/Tools/ChangeLog 2020-07-14 23:10:11 UTC (rev 264381)
+++ trunk/Tools/ChangeLog 2020-07-14 23:36:58 UTC (rev 264382)
@@ -1,3 +1,17 @@
+2020-07-14 Alex Christensen <achristen...@webkit.org>
+
+ REGRESSION(r262341) URL::createCFURL should produce a CFURL that uses UTF-8 to decode its percent-encoded sequences
+ https://bugs.webkit.org/show_bug.cgi?id=214314
+ <rdar://problem/65079249>
+
+ Reviewed by Darin Adler.
+
+ * TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm:
+ Add a direct test and update the Mojave test expectations for the test introduced in r262341 with the change that introduced this regression.
+ * TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm:
+ Update a test from r263475 which fixed another regression from r262341.
+ The test verified that nothing crashed or timed out, and that is still the case even with this intentional change in behavior.
+
2020-07-14 Wenson Hsieh <wenson_hs...@apple.com>
[iOS] The completion handler in -handleKeyWebEvent:withCompletionHandler: is sometimes never called
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm (264381 => 264382)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm 2020-07-14 23:10:11 UTC (rev 264381)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm 2020-07-14 23:36:58 UTC (rev 264382)
@@ -218,13 +218,13 @@
WTF::URL url4(URL(), String(latin1.data()));
EXPECT_FALSE(url4.isValid());
EXPECT_TRUE(url4.string().is8Bit());
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED < 101500
- // CFURLCreateAbsoluteURLWithBytes has incorrect behavior on Mojave
- // See https://bugs.webkit.org/show_bug.cgi?id=212486#c6
- EXPECT_STREQ([[url4 absoluteString] UTF8String], "%C2%B6");
-#else
EXPECT_STREQ([[url4 absoluteString] UTF8String], "%C3%82%C2%B6");
-#endif
+
+ char buffer[100];
+ memset(buffer, 0, sizeof(buffer));
+ WTF::URL url5(URL(), "file:///A%C3%A7%C3%A3o.html"_s);
+ CFURLGetFileSystemRepresentation(url5.createCFURL().get(), false, reinterpret_cast<UInt8*>(buffer), sizeof(buffer));
+ EXPECT_STREQ(buffer, "/Ação.html");
}
TEST(WTF_URLExtras, URLExtras_Nil)
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm (264381 => 264382)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm 2020-07-14 23:10:11 UTC (rev 264381)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm 2020-07-14 23:36:58 UTC (rev 264382)
@@ -93,7 +93,7 @@
delegate.get().didFailProvisionalNavigation = ^(WKWebView *, WKNavigation *, NSError *error) {
EXPECT_WK_STREQ(error.domain, @"WebKitErrorDomain");
EXPECT_EQ(error.code, WebKitErrorCannotShowURL);
- EXPECT_WK_STREQ([error.userInfo[@"NSErrorFailingURLKey"] absoluteString], "http://%E2%80%80");
+ EXPECT_WK_STREQ([error.userInfo[@"NSErrorFailingURLKey"] absoluteString], "http://%C3%A2%C2%80%C2%80");
done = true;
};
auto webView = adoptNS([WKWebView new]);