Changeset 264382 in webkit
- Timestamp:
- Jul 14, 2020, 4:36:58 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r264367 r264382 1 2020-07-14 Alex Christensen <achristensen@webkit.org> 2 3 REGRESSION(r262341) URL::createCFURL should produce a CFURL that uses UTF-8 to decode its percent-encoded sequences 4 https://bugs.webkit.org/show_bug.cgi?id=214314 5 <rdar://problem/65079249> 6 7 Reviewed by Darin Adler. 8 9 r262341 made it so we usually pass kCFStringEncodingISOLatin1 into CFURLCreateAbsoluteURLWithBytes when creating a CFURLRef from a WTF::URL. 10 This is correct for the interpretation of the bytes to create a CFStringRef, and that is a change we want to make. 11 The encoding, however, is also stored with the CFURL and used later when interpreting percent-encoded sequences. 12 We want to use kCFStringEncodingUTF8 to make the interpretation of percent-encoded sequences the same as it used to be. 13 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. 14 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. 15 16 * wtf/cf/URLCF.cpp: 17 (WTF::URL::createCFURL const): 18 * wtf/cocoa/URLCocoa.mm: 19 (WTF::URL::createCFURL const): 20 1 21 2020-07-14 Jer Noble <jer.noble@apple.com> 2 22 -
trunk/Source/WTF/wtf/cf/URLCF.cpp
r262341 r264382 52 52 { 53 53 RetainPtr<CFURLRef> cfURL; 54 if (LIKELY(m_string.is8Bit() ))55 cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(m_string.characters8()), m_string.length(), kCFStringEncoding ISOLatin1, nullptr, true));54 if (LIKELY(m_string.is8Bit() && m_string.isAllASCII())) 55 cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(m_string.characters8()), m_string.length(), kCFStringEncodingUTF8, nullptr, true)); 56 56 else { 57 57 CString utf8 = m_string.utf8(); -
trunk/Source/WTF/wtf/cocoa/URLCocoa.mm
r262341 r264382 70 70 71 71 RetainPtr<CFURLRef> cfURL; 72 if (LIKELY(m_string.is8Bit() ))73 cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(m_string.characters8()), m_string.length(), kCFStringEncoding ISOLatin1, nullptr, true));72 if (LIKELY(m_string.is8Bit() && m_string.isAllASCII())) 73 cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(m_string.characters8()), m_string.length(), kCFStringEncodingUTF8, nullptr, true)); 74 74 else { 75 75 CString utf8 = m_string.utf8(); -
trunk/Tools/ChangeLog
r264376 r264382 1 2020-07-14 Alex Christensen <achristensen@webkit.org> 2 3 REGRESSION(r262341) URL::createCFURL should produce a CFURL that uses UTF-8 to decode its percent-encoded sequences 4 https://bugs.webkit.org/show_bug.cgi?id=214314 5 <rdar://problem/65079249> 6 7 Reviewed by Darin Adler. 8 9 * TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm: 10 Add a direct test and update the Mojave test expectations for the test introduced in r262341 with the change that introduced this regression. 11 * TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm: 12 Update a test from r263475 which fixed another regression from r262341. 13 The test verified that nothing crashed or timed out, and that is still the case even with this intentional change in behavior. 14 1 15 2020-07-14 Wenson Hsieh <wenson_hsieh@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm
r262341 r264382 219 219 EXPECT_FALSE(url4.isValid()); 220 220 EXPECT_TRUE(url4.string().is8Bit()); 221 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED < 101500222 // CFURLCreateAbsoluteURLWithBytes has incorrect behavior on Mojave223 // See https://bugs.webkit.org/show_bug.cgi?id=212486#c6224 EXPECT_STREQ([[url4 absoluteString] UTF8String], "%C2%B6");225 #else226 221 EXPECT_STREQ([[url4 absoluteString] UTF8String], "%C3%82%C2%B6"); 227 #endif 222 223 char buffer[100]; 224 memset(buffer, 0, sizeof(buffer)); 225 WTF::URL url5(URL(), "file:///A%C3%A7%C3%A3o.html"_s); 226 CFURLGetFileSystemRepresentation(url5.createCFURL().get(), false, reinterpret_cast<UInt8*>(buffer), sizeof(buffer)); 227 EXPECT_STREQ(buffer, "/Ação.html"); 228 228 } 229 229 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm
r263475 r264382 94 94 EXPECT_WK_STREQ(error.domain, @"WebKitErrorDomain"); 95 95 EXPECT_EQ(error.code, WebKitErrorCannotShowURL); 96 EXPECT_WK_STREQ([error.userInfo[@"NSErrorFailingURLKey"] absoluteString], "http://% E2%80%80");96 EXPECT_WK_STREQ([error.userInfo[@"NSErrorFailingURLKey"] absoluteString], "http://%C3%A2%C2%80%C2%80"); 97 97 done = true; 98 98 };
Note:
See TracChangeset
for help on using the changeset viewer.