RESOLVED FIXED 210431
Move URL to use StringView when returning substrings of the URL
https://bugs.webkit.org/show_bug.cgi?id=210431
Summary Move URL to use StringView when returning substrings of the URL
Darin Adler
Reported 2020-04-13 09:07:09 PDT
Move URL to use StringView when returning substrings of the URL
Attachments
Patch (163.63 KB, patch)
2020-04-13 19:24 PDT, Darin Adler
no flags
Patch (165.80 KB, patch)
2020-04-13 20:29 PDT, Darin Adler
no flags
Patch (170.66 KB, patch)
2020-04-13 20:40 PDT, Darin Adler
no flags
Patch (176.88 KB, patch)
2020-04-14 09:49 PDT, Darin Adler
no flags
Patch (186.47 KB, patch)
2020-04-17 10:27 PDT, Darin Adler
no flags
Patch (190.43 KB, patch)
2020-04-20 12:42 PDT, Darin Adler
no flags
Patch (198.74 KB, patch)
2020-04-21 21:29 PDT, Darin Adler
no flags
Patch (209.15 KB, patch)
2020-04-22 18:11 PDT, Darin Adler
no flags
Patch (217.35 KB, patch)
2020-04-22 22:00 PDT, Darin Adler
no flags
Patch (217.40 KB, patch)
2020-04-23 18:40 PDT, Darin Adler
no flags
Patch (218.67 KB, patch)
2020-04-24 09:30 PDT, Darin Adler
no flags
Patch (221.08 KB, patch)
2020-04-24 11:30 PDT, Darin Adler
andersca: review+
Darin Adler
Comment 1 2020-04-13 19:24:36 PDT Comment hidden (obsolete)
Darin Adler
Comment 2 2020-04-13 20:29:21 PDT Comment hidden (obsolete)
Darin Adler
Comment 3 2020-04-13 20:40:52 PDT Comment hidden (obsolete)
Darin Adler
Comment 4 2020-04-14 09:49:05 PDT Comment hidden (obsolete)
Darin Adler
Comment 5 2020-04-17 10:27:02 PDT Comment hidden (obsolete)
Darin Adler
Comment 6 2020-04-20 12:42:48 PDT Comment hidden (obsolete)
Darin Adler
Comment 7 2020-04-21 21:29:19 PDT Comment hidden (obsolete)
Darin Adler
Comment 8 2020-04-22 18:11:05 PDT Comment hidden (obsolete)
Darin Adler
Comment 9 2020-04-22 22:00:46 PDT Comment hidden (obsolete)
Darin Adler
Comment 10 2020-04-23 18:40:06 PDT Comment hidden (obsolete)
Darin Adler
Comment 11 2020-04-24 09:30:52 PDT
Darin Adler
Comment 12 2020-04-24 11:30:44 PDT
Anders Carlsson
Comment 13 2020-04-25 08:02:15 PDT
Comment on attachment 397474 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=397474&action=review > Source/WTF/wtf/URL.cpp:169 > + Vector<LChar, 512> percentDecoded; 512 seems kinda arbitrary and a little high. > Source/WTF/wtf/text/StringView.cpp:315 > +// FIXME: Should this be named parseNumber<uint16_t> instead? I like this idea. > Source/WebCore/loader/appcache/ManifestParser.cpp:38 > +static StringView manifestPath(const URL& manifestURL) Need to be careful about passing temporaries to this function! > Source/WebCore/platform/network/curl/CurlProxySettings.cpp:40 > +constexpr uint16_t SocksProxyPort = 1080; I'd keep this static. > Source/WebCore/platform/win/PasteboardWin.cpp:-582 > - String lastComponent = kurl.lastPathComponent(); kurl! > Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp:1127 > + || isPublicSuffix(m_currentRequest.url().host().toStringWithoutCopying()); Surprised isPublicSuffic doesn't take a StringView. > Source/WebKitLegacy/win/Plugins/PluginDatabase.cpp:2 > + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. Maybe change the copyright years here too.
Darin Adler
Comment 14 2020-04-25 11:01:53 PDT
Comment on attachment 397474 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=397474&action=review >> Source/WTF/wtf/URL.cpp:169 >> + Vector<LChar, 512> percentDecoded; > > 512 seems kinda arbitrary and a little high. Was matching the other 512 numbers elsewhere in URL code, but those are for lengths of entire URLs. I would be happy to choose a different arbitrary number here. Maybe I should do a histogram of how this is actually used when doing some web browsing. For now, I’ll put 100 instead of 512 and I’ll even add a FIXME about setting the number better. >> Source/WTF/wtf/text/StringView.cpp:315 >> +// FIXME: Should this be named parseNumber<uint16_t> instead? > > I like this idea. Just for the moment, I will leave it like this with this FIXME. But I will follow up. >> Source/WebCore/loader/appcache/ManifestParser.cpp:38 >> +static StringView manifestPath(const URL& manifestURL) > > Need to be careful about passing temporaries to this function! Good point. Also true about all the URL functions; I did make them more dangerous with temporaries too. Any thoughts on what I should do to lower the risk? >> Source/WebCore/platform/network/curl/CurlProxySettings.cpp:40 >> +constexpr uint16_t SocksProxyPort = 1080; > > I'd keep this static. Alexey told me in the past that I should not write static in front of numeric constants in .cpp files. I will change this one back, but I am a bit confused about the tradeoffs. I looked it up and it seems that constexpr does not affect external vs. internal linkage, although it does make both "inline" and "const" redundant and unnecessary. >> Source/WebCore/platform/win/PasteboardWin.cpp:-582 >> - String lastComponent = kurl.lastPathComponent(); > > kurl! I will leave this as a warning to future explorers, a concise way to say: "Abandon all hope, ye who enter here." >> Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp:1127 >> + || isPublicSuffix(m_currentRequest.url().host().toStringWithoutCopying()); > > Surprised isPublicSuffic doesn't take a StringView. The Mac implementation easily could: it just creates a CF/NSString. It would take a little more work to wean the curl and soup implementations off of the convertToLowercaseWithoutLocale (incorrect in the curl one), convertToASCIILowercase (correct in the soup one), and utf8 functions. And this is soup-specific code. I won’t do anything about this at this time.
Darin Adler
Comment 15 2020-04-25 11:02:02 PDT
Radar WebKit Bug Importer
Comment 16 2020-04-25 11:02:23 PDT
youenn fablet
Comment 17 2020-04-29 00:36:58 PDT
Comment on attachment 397474 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=397474&action=review > Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp:54 > + url.setPort(origin.port()); We should probably reintroduce the nullopt check here. > Source/WebCore/workers/service/server/SWServer.cpp:430 > + url.setPort(*origin.port()); Ditto here.
youenn fablet
Comment 18 2020-04-29 00:38:48 PDT
(In reply to youenn fablet from comment #17) > Comment on attachment 397474 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=397474&action=review > > > Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp:54 > > + url.setPort(origin.port()); > > We should probably reintroduce the nullopt check here. > > > Source/WebCore/workers/service/server/SWServer.cpp:430 > > + url.setPort(*origin.port()); > > Ditto here. Actually no, just remove * from SWServer.cpp:430
Note You need to log in before you can comment on or make changes to this bug.