Bug 214314

Summary: REGRESSION(r262341) URL::createCFURL should produce a CFURL that uses UTF-8 to decode its percent-encoded sequences
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: Web Template FrameworkAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, darin, ews-watchlist, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=222145
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Alex Christensen
Reported 2020-07-14 12:32:24 PDT
REGRESSION(r262341) URL::createCFURL should produce a CFURL that uses UTF-8 to decode its percent-encoded sequences
Attachments
Patch (5.24 KB, patch)
2020-07-14 13:05 PDT, Alex Christensen
no flags
Patch (6.87 KB, patch)
2020-07-14 14:00 PDT, Alex Christensen
no flags
Patch (6.61 KB, patch)
2020-07-14 15:58 PDT, Alex Christensen
no flags
Alex Christensen
Comment 1 2020-07-14 13:05:06 PDT
Alex Christensen
Comment 2 2020-07-14 14:00:39 PDT
Darin Adler
Comment 3 2020-07-14 14:46:21 PDT
Comment on attachment 404281 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=404281&action=review > Source/WTF/wtf/cf/URLCF.cpp:56 > +struct PartialCFURL { > + uintptr_t unused1; > + uintptr_t unused2; > + uint32_t unused3; > + CFStringEncoding encoding; > +}; I suppose this is OK for the short term, but for the future need CFURL API or at *least* SPI. Please make *sure* you get the ball rolling on that. This seems like an accident waiting to happen! I’d prefer that this technique be put into its own separate named function, not be done inline in the middle of URL::createCFURL. If we knew what the API/SPI was going to be, maybe we could name our function based on that. But I have a suggestion that allows us to avoid this whole mess, with a small additional performance cost. > Source/WTF/wtf/cf/URLCF.cpp:62 > + if (LIKELY(m_string.is8Bit())) { > cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(m_string.characters8()), m_string.length(), kCFStringEncodingISOLatin1, nullptr, true)); Instead of the change here, I propose we instead do this: 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 ... Later if we get some API or SPI, we can optimize further using that, but we don’t need to do this change just to get correct behavior.
Alex Christensen
Comment 4 2020-07-14 15:57:40 PDT
Comment on attachment 404281 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=404281&action=review >> Source/WTF/wtf/cf/URLCF.cpp:62 >> cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(m_string.characters8()), m_string.length(), kCFStringEncodingISOLatin1, nullptr, true)); > > Instead of the change here, I propose we instead do this: > > 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 > ... > > Later if we get some API or SPI, we can optimize further using that, but we don’t need to do this change just to get correct behavior. That works great, and doesn't do horrible things like my original patch does. ASCII checks are considerably faster than parsing URLs, so I don't anticipate the perf hit to be too bad.
Alex Christensen
Comment 5 2020-07-14 15:58:13 PDT
EWS
Comment 6 2020-07-14 16:37:03 PDT
Committed r264382: <https://trac.webkit.org/changeset/264382> All reviewed patches have been landed. Closing bug and clearing flags on attachment 404299 [details].
Radar WebKit Bug Importer
Comment 7 2020-07-14 16:38:14 PDT
Note You need to log in before you can comment on or make changes to this bug.