2016-08-11 19:09:39 +00:00
|
|
|
/*
|
Non-special URLs are not idempotent
https://bugs.webkit.org/show_bug.cgi?id=215762
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/url-constructor-expected.txt:
* web-platform-tests/url/url-setters-expected.txt:
Source/WTF:
https://github.com/whatwg/url/pull/505 added an interesting edge case to the URL serialization:
"If url’s host is null, url’s path’s size is greater than 1, and url’s path[0] is the empty string, then append U+002F (/) followed by U+002E (.) to output."
The problem was that URLs like "a:/a/..//a" would be parsed into "a://a" with a pathname of "//a" and an empty host. If "a://a" was then reparsed, it would again have an href of "a://a"
but its host would be "a" and it would have an empty path. There is consensus that URL parsing should be idempotent, so we need to do something different here.
According to https://github.com/whatwg/url/issues/415#issuecomment-419197290 this follows what Edge did (and then subsequently abandoned when they switched to Chromium)
to make URL parsing idempotent by adding "/." before the path in the edge case of a URL with a non-special scheme (not http, https, wss, etc.) and a null host and a non-empty path that
has an empty first segment. All the members of the URL remain unchanged except the full serialization (href). This is not important in practice, but important in theory.
Our URL parser tries very hard to use the exact same WTF::String object given as input if it can. However, this step is better implemented as a post-processing step that will almost never happen
because otherwise we would have to parse the entire path twice to find out if we need to add "./" or if the "./" that may have already been there needs to stay. This is illustrated with the test URL
"t:/.//p/../../../..//x" which does need the "./".
In the common case, this adds one well-predicted branch to URL parsing, so I expect performance to be unaffected. Since this is such a rare edge case of URLs, I expect no compatibility problems.
* wtf/URL.cpp:
(WTF::URL::pathStart const):
* wtf/URL.h:
(WTF::URL::pathStart const): Deleted.
* wtf/URLParser.cpp:
(WTF::URLParser::copyURLPartsUntil):
(WTF::URLParser::URLParser):
(WTF::URLParser::needsNonSpecialDotSlash const):
(WTF::URLParser::addNonSpecialDotSlash):
* wtf/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WTF/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/229956@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267837 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-01 17:05:41 +00:00
|
|
|
* Copyright (C) 2016-2020 Apple Inc. All rights reserved.
|
2016-08-11 19:09:39 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2018-12-01 03:28:36 +00:00
|
|
|
#include <wtf/URLParser.h>
|
2016-08-12 20:03:49 +00:00
|
|
|
|
2016-08-22 05:42:12 +00:00
|
|
|
#include <array>
|
Support IDN2008 with UTS #46 instead of IDN2003
https://bugs.webkit.org/show_bug.cgi?id=144194
Reviewed by Darin Adler.
Source/WebCore:
Use uidna_nameToASCII instead of the deprecated uidna_IDNToASCII.
It uses IDN2008 instead of IDN2003, and it uses UTF #46 when used with a UIDNA opened with uidna_openUTS46.
This follows https://url.spec.whatwg.org/#concept-domain-to-ascii except we do not use Transitional_Processing
to prevent homograph attacks on german domain names with "ß" and "ss" in them. These are now treated as separate domains.
Firefox also doesn't use Transitional_Processing. Chrome and the current specification use Transitional_processing,
but https://github.com/whatwg/url/issues/110 might change the spec.
In addition, http://unicode.org/reports/tr46/ says:
"implementations are encouraged to apply the Bidi and ContextJ validity criteria"
Bidi checks prevent domain names with bidirectional text, such as latin and hebrew characters in the same domain. Chrome and Firefox do this.
ContextJ checks prevent code points such as U+200D, which is a zero-width joiner which users would not see when looking at the domain name.
Firefox currently enables ContextJ checks and it is suggested by UTS #46, so we'll do it.
ContextO checks, which we do not use and neither does any other browser nor the spec, would fail if a domain contains code points such as U+30FB,
which looks somewhat like a dot. We can investigate enabling these checks later.
Covered by new API tests and rebased LayoutTests.
The new API tests verify that we do not use transitional processing, that we do apply the Bidi and ContextJ checks, but not ContextO checks.
* platform/URLParser.cpp:
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::internationalDomainNameTranscoder):
* platform/URLParser.h:
* platform/mac/WebCoreNSURLExtras.mm:
(WebCore::mapHostNameWithRange):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Add some tests from http://unicode.org/faq/idn.html verifying that we follow UTS46's deviations from IDN2008.
Add some tests based on https://tools.ietf.org/html/rfc5893 verifying that we check for bidirectional text.
Add a test based on https://tools.ietf.org/html/rfc5892 verifying that we do not do ContextO check.
Add a test for U+321D and U+321E which have particularly interesting punycode encodings. We match Firefox here now.
Also add a test from http://www.unicode.org/reports/tr46/#IDNAComparison verifying we are not using IDN2003.
We should consider importing all of http://www.unicode.org/Public/idna/9.0.0/IdnaTest.txt as URL domain tests.
LayoutTests:
* fast/encoding/idn-security.html:
Move some characters with changed IDN encodings to inside the check for old ICU.
* fast/url/idna2003-expected.txt:
* fast/url/idna2008-expected.txt:
Update expected results. We are now more compliant with IDN2008.
Canonical link: https://commits.webkit.org/182613@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208902 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-18 22:47:24 +00:00
|
|
|
#include <mutex>
|
2020-08-31 15:51:14 +00:00
|
|
|
#include <wtf/text/CodePointIterator.h>
|
2016-08-11 19:09:39 +00:00
|
|
|
|
2018-12-01 03:28:36 +00:00
|
|
|
namespace WTF {
|
2016-08-11 19:09:39 +00:00
|
|
|
|
2016-10-07 19:03:13 +00:00
|
|
|
#define URL_PARSER_DEBUGGING 0
|
2017-01-21 00:44:48 +00:00
|
|
|
|
2016-10-07 19:03:13 +00:00
|
|
|
#if URL_PARSER_DEBUGGING
|
2018-12-01 03:28:36 +00:00
|
|
|
#define URL_PARSER_LOG(...) WTFLogAlways(__VA_ARGS__)
|
2016-10-07 19:03:13 +00:00
|
|
|
#else
|
|
|
|
#define URL_PARSER_LOG(...)
|
|
|
|
#endif
|
2016-09-15 18:12:09 +00:00
|
|
|
|
2016-09-28 01:23:50 +00:00
|
|
|
ALWAYS_INLINE static void appendCodePoint(Vector<UChar>& destination, UChar32 codePoint)
|
2016-09-20 21:50:30 +00:00
|
|
|
{
|
|
|
|
if (U_IS_BMP(codePoint)) {
|
|
|
|
destination.append(static_cast<UChar>(codePoint));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
destination.reserveCapacity(destination.size() + 2);
|
|
|
|
destination.uncheckedAppend(U16_LEAD(codePoint));
|
|
|
|
destination.uncheckedAppend(U16_TRAIL(codePoint));
|
|
|
|
}
|
2016-09-15 18:12:09 +00:00
|
|
|
|
2016-09-15 18:48:45 +00:00
|
|
|
enum URLCharacterClass {
|
|
|
|
UserInfo = 0x1,
|
|
|
|
Default = 0x2,
|
2017-02-13 22:52:34 +00:00
|
|
|
ForbiddenHost = 0x4,
|
2016-09-15 18:48:45 +00:00
|
|
|
QueryPercent = 0x8,
|
|
|
|
SlashQuestionOrHash = 0x10,
|
2016-10-05 18:25:02 +00:00
|
|
|
ValidScheme = 0x20,
|
2016-09-15 18:48:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const uint8_t characterClassTable[256] = {
|
2017-02-13 22:52:34 +00:00
|
|
|
UserInfo | Default | QueryPercent | ForbiddenHost, // 0x0
|
2016-09-15 18:48:45 +00:00
|
|
|
UserInfo | Default | QueryPercent, // 0x1
|
|
|
|
UserInfo | Default | QueryPercent, // 0x2
|
|
|
|
UserInfo | Default | QueryPercent, // 0x3
|
|
|
|
UserInfo | Default | QueryPercent, // 0x4
|
|
|
|
UserInfo | Default | QueryPercent, // 0x5
|
|
|
|
UserInfo | Default | QueryPercent, // 0x6
|
|
|
|
UserInfo | Default | QueryPercent, // 0x7
|
|
|
|
UserInfo | Default | QueryPercent, // 0x8
|
2017-02-13 22:52:34 +00:00
|
|
|
UserInfo | Default | QueryPercent | ForbiddenHost, // 0x9
|
|
|
|
UserInfo | Default | QueryPercent | ForbiddenHost, // 0xA
|
2016-09-15 18:48:45 +00:00
|
|
|
UserInfo | Default | QueryPercent, // 0xB
|
|
|
|
UserInfo | Default | QueryPercent, // 0xC
|
2017-02-13 22:52:34 +00:00
|
|
|
UserInfo | Default | QueryPercent | ForbiddenHost, // 0xD
|
2016-09-15 18:48:45 +00:00
|
|
|
UserInfo | Default | QueryPercent, // 0xE
|
|
|
|
UserInfo | Default | QueryPercent, // 0xF
|
|
|
|
UserInfo | Default | QueryPercent, // 0x10
|
|
|
|
UserInfo | Default | QueryPercent, // 0x11
|
|
|
|
UserInfo | Default | QueryPercent, // 0x12
|
|
|
|
UserInfo | Default | QueryPercent, // 0x13
|
|
|
|
UserInfo | Default | QueryPercent, // 0x14
|
|
|
|
UserInfo | Default | QueryPercent, // 0x15
|
|
|
|
UserInfo | Default | QueryPercent, // 0x16
|
|
|
|
UserInfo | Default | QueryPercent, // 0x17
|
|
|
|
UserInfo | Default | QueryPercent, // 0x18
|
|
|
|
UserInfo | Default | QueryPercent, // 0x19
|
|
|
|
UserInfo | Default | QueryPercent, // 0x1A
|
|
|
|
UserInfo | Default | QueryPercent, // 0x1B
|
|
|
|
UserInfo | Default | QueryPercent, // 0x1C
|
|
|
|
UserInfo | Default | QueryPercent, // 0x1D
|
|
|
|
UserInfo | Default | QueryPercent, // 0x1E
|
|
|
|
UserInfo | Default | QueryPercent, // 0x1F
|
2017-02-13 22:52:34 +00:00
|
|
|
UserInfo | Default | QueryPercent | ForbiddenHost, // ' '
|
2016-09-15 18:48:45 +00:00
|
|
|
0, // '!'
|
|
|
|
UserInfo | Default | QueryPercent, // '"'
|
2017-02-13 22:52:34 +00:00
|
|
|
UserInfo | Default | QueryPercent | SlashQuestionOrHash | ForbiddenHost, // '#'
|
2016-09-15 18:48:45 +00:00
|
|
|
0, // '$'
|
2017-02-13 22:52:34 +00:00
|
|
|
ForbiddenHost, // '%'
|
2016-09-15 18:48:45 +00:00
|
|
|
0, // '&'
|
2018-01-05 23:38:26 +00:00
|
|
|
0, // '\''
|
2016-09-15 18:48:45 +00:00
|
|
|
0, // '('
|
|
|
|
0, // ')'
|
|
|
|
0, // '*'
|
2016-10-05 18:25:02 +00:00
|
|
|
ValidScheme, // '+'
|
2016-09-15 18:48:45 +00:00
|
|
|
0, // ','
|
2016-10-05 18:25:02 +00:00
|
|
|
ValidScheme, // '-'
|
|
|
|
ValidScheme, // '.'
|
2017-02-13 22:52:34 +00:00
|
|
|
UserInfo | SlashQuestionOrHash | ForbiddenHost, // '/'
|
2016-10-05 18:25:02 +00:00
|
|
|
ValidScheme, // '0'
|
|
|
|
ValidScheme, // '1'
|
|
|
|
ValidScheme, // '2'
|
|
|
|
ValidScheme, // '3'
|
|
|
|
ValidScheme, // '4'
|
|
|
|
ValidScheme, // '5'
|
|
|
|
ValidScheme, // '6'
|
|
|
|
ValidScheme, // '7'
|
|
|
|
ValidScheme, // '8'
|
|
|
|
ValidScheme, // '9'
|
2017-02-13 22:52:34 +00:00
|
|
|
UserInfo | ForbiddenHost, // ':'
|
2016-09-15 18:48:45 +00:00
|
|
|
UserInfo, // ';'
|
2018-01-05 23:38:26 +00:00
|
|
|
UserInfo | Default | QueryPercent | ForbiddenHost, // '<'
|
2016-09-15 18:48:45 +00:00
|
|
|
UserInfo, // '='
|
2018-01-05 23:38:26 +00:00
|
|
|
UserInfo | Default | QueryPercent | ForbiddenHost, // '>'
|
2017-02-13 22:52:34 +00:00
|
|
|
UserInfo | Default | SlashQuestionOrHash | ForbiddenHost, // '?'
|
|
|
|
UserInfo | ForbiddenHost, // '@'
|
2016-10-05 18:25:02 +00:00
|
|
|
ValidScheme, // 'A'
|
|
|
|
ValidScheme, // 'B'
|
|
|
|
ValidScheme, // 'C'
|
|
|
|
ValidScheme, // 'D'
|
|
|
|
ValidScheme, // 'E'
|
|
|
|
ValidScheme, // 'F'
|
|
|
|
ValidScheme, // 'G'
|
|
|
|
ValidScheme, // 'H'
|
|
|
|
ValidScheme, // 'I'
|
|
|
|
ValidScheme, // 'J'
|
|
|
|
ValidScheme, // 'K'
|
|
|
|
ValidScheme, // 'L'
|
|
|
|
ValidScheme, // 'M'
|
|
|
|
ValidScheme, // 'N'
|
|
|
|
ValidScheme, // 'O'
|
|
|
|
ValidScheme, // 'P'
|
|
|
|
ValidScheme, // 'Q'
|
|
|
|
ValidScheme, // 'R'
|
|
|
|
ValidScheme, // 'S'
|
|
|
|
ValidScheme, // 'T'
|
|
|
|
ValidScheme, // 'U'
|
|
|
|
ValidScheme, // 'V'
|
|
|
|
ValidScheme, // 'W'
|
|
|
|
ValidScheme, // 'X'
|
|
|
|
ValidScheme, // 'Y'
|
|
|
|
ValidScheme, // 'Z'
|
2017-02-13 22:52:34 +00:00
|
|
|
UserInfo | ForbiddenHost, // '['
|
|
|
|
UserInfo | SlashQuestionOrHash | ForbiddenHost, // '\\'
|
|
|
|
UserInfo | ForbiddenHost, // ']'
|
2020-05-15 21:55:30 +00:00
|
|
|
UserInfo | ForbiddenHost, // '^'
|
2016-09-15 18:48:45 +00:00
|
|
|
0, // '_'
|
|
|
|
UserInfo | Default, // '`'
|
2016-10-05 18:25:02 +00:00
|
|
|
ValidScheme, // 'a'
|
|
|
|
ValidScheme, // 'b'
|
|
|
|
ValidScheme, // 'c'
|
|
|
|
ValidScheme, // 'd'
|
|
|
|
ValidScheme, // 'e'
|
|
|
|
ValidScheme, // 'f'
|
|
|
|
ValidScheme, // 'g'
|
|
|
|
ValidScheme, // 'h'
|
|
|
|
ValidScheme, // 'i'
|
|
|
|
ValidScheme, // 'j'
|
|
|
|
ValidScheme, // 'k'
|
|
|
|
ValidScheme, // 'l'
|
|
|
|
ValidScheme, // 'm'
|
|
|
|
ValidScheme, // 'n'
|
|
|
|
ValidScheme, // 'o'
|
|
|
|
ValidScheme, // 'p'
|
|
|
|
ValidScheme, // 'q'
|
|
|
|
ValidScheme, // 'r'
|
|
|
|
ValidScheme, // 's'
|
|
|
|
ValidScheme, // 't'
|
|
|
|
ValidScheme, // 'u'
|
|
|
|
ValidScheme, // 'v'
|
|
|
|
ValidScheme, // 'w'
|
|
|
|
ValidScheme, // 'x'
|
|
|
|
ValidScheme, // 'y'
|
|
|
|
ValidScheme, // 'z'
|
2016-09-15 18:48:45 +00:00
|
|
|
UserInfo | Default, // '{'
|
2021-01-26 21:14:33 +00:00
|
|
|
UserInfo | ForbiddenHost, // '|'
|
2016-09-15 18:48:45 +00:00
|
|
|
UserInfo | Default, // '}'
|
|
|
|
0, // '~'
|
|
|
|
QueryPercent, // 0x7F
|
|
|
|
QueryPercent, // 0x80
|
|
|
|
QueryPercent, // 0x81
|
|
|
|
QueryPercent, // 0x82
|
|
|
|
QueryPercent, // 0x83
|
|
|
|
QueryPercent, // 0x84
|
|
|
|
QueryPercent, // 0x85
|
|
|
|
QueryPercent, // 0x86
|
|
|
|
QueryPercent, // 0x87
|
|
|
|
QueryPercent, // 0x88
|
|
|
|
QueryPercent, // 0x89
|
|
|
|
QueryPercent, // 0x8A
|
|
|
|
QueryPercent, // 0x8B
|
|
|
|
QueryPercent, // 0x8C
|
|
|
|
QueryPercent, // 0x8D
|
|
|
|
QueryPercent, // 0x8E
|
|
|
|
QueryPercent, // 0x8F
|
|
|
|
QueryPercent, // 0x90
|
|
|
|
QueryPercent, // 0x91
|
|
|
|
QueryPercent, // 0x92
|
|
|
|
QueryPercent, // 0x93
|
|
|
|
QueryPercent, // 0x94
|
|
|
|
QueryPercent, // 0x95
|
|
|
|
QueryPercent, // 0x96
|
|
|
|
QueryPercent, // 0x97
|
|
|
|
QueryPercent, // 0x98
|
|
|
|
QueryPercent, // 0x99
|
|
|
|
QueryPercent, // 0x9A
|
|
|
|
QueryPercent, // 0x9B
|
|
|
|
QueryPercent, // 0x9C
|
|
|
|
QueryPercent, // 0x9D
|
|
|
|
QueryPercent, // 0x9E
|
|
|
|
QueryPercent, // 0x9F
|
|
|
|
QueryPercent, // 0xA0
|
|
|
|
QueryPercent, // 0xA1
|
|
|
|
QueryPercent, // 0xA2
|
|
|
|
QueryPercent, // 0xA3
|
|
|
|
QueryPercent, // 0xA4
|
|
|
|
QueryPercent, // 0xA5
|
|
|
|
QueryPercent, // 0xA6
|
|
|
|
QueryPercent, // 0xA7
|
|
|
|
QueryPercent, // 0xA8
|
|
|
|
QueryPercent, // 0xA9
|
|
|
|
QueryPercent, // 0xAA
|
|
|
|
QueryPercent, // 0xAB
|
|
|
|
QueryPercent, // 0xAC
|
|
|
|
QueryPercent, // 0xAD
|
|
|
|
QueryPercent, // 0xAE
|
|
|
|
QueryPercent, // 0xAF
|
|
|
|
QueryPercent, // 0xB0
|
|
|
|
QueryPercent, // 0xB1
|
|
|
|
QueryPercent, // 0xB2
|
|
|
|
QueryPercent, // 0xB3
|
|
|
|
QueryPercent, // 0xB4
|
|
|
|
QueryPercent, // 0xB5
|
|
|
|
QueryPercent, // 0xB6
|
|
|
|
QueryPercent, // 0xB7
|
|
|
|
QueryPercent, // 0xB8
|
|
|
|
QueryPercent, // 0xB9
|
|
|
|
QueryPercent, // 0xBA
|
|
|
|
QueryPercent, // 0xBB
|
|
|
|
QueryPercent, // 0xBC
|
|
|
|
QueryPercent, // 0xBD
|
|
|
|
QueryPercent, // 0xBE
|
|
|
|
QueryPercent, // 0xBF
|
|
|
|
QueryPercent, // 0xC0
|
|
|
|
QueryPercent, // 0xC1
|
|
|
|
QueryPercent, // 0xC2
|
|
|
|
QueryPercent, // 0xC3
|
|
|
|
QueryPercent, // 0xC4
|
|
|
|
QueryPercent, // 0xC5
|
|
|
|
QueryPercent, // 0xC6
|
|
|
|
QueryPercent, // 0xC7
|
|
|
|
QueryPercent, // 0xC8
|
|
|
|
QueryPercent, // 0xC9
|
|
|
|
QueryPercent, // 0xCA
|
|
|
|
QueryPercent, // 0xCB
|
|
|
|
QueryPercent, // 0xCC
|
|
|
|
QueryPercent, // 0xCD
|
|
|
|
QueryPercent, // 0xCE
|
|
|
|
QueryPercent, // 0xCF
|
|
|
|
QueryPercent, // 0xD0
|
|
|
|
QueryPercent, // 0xD1
|
|
|
|
QueryPercent, // 0xD2
|
|
|
|
QueryPercent, // 0xD3
|
|
|
|
QueryPercent, // 0xD4
|
|
|
|
QueryPercent, // 0xD5
|
|
|
|
QueryPercent, // 0xD6
|
|
|
|
QueryPercent, // 0xD7
|
|
|
|
QueryPercent, // 0xD8
|
|
|
|
QueryPercent, // 0xD9
|
|
|
|
QueryPercent, // 0xDA
|
|
|
|
QueryPercent, // 0xDB
|
|
|
|
QueryPercent, // 0xDC
|
|
|
|
QueryPercent, // 0xDD
|
|
|
|
QueryPercent, // 0xDE
|
|
|
|
QueryPercent, // 0xDF
|
|
|
|
QueryPercent, // 0xE0
|
|
|
|
QueryPercent, // 0xE1
|
|
|
|
QueryPercent, // 0xE2
|
|
|
|
QueryPercent, // 0xE3
|
|
|
|
QueryPercent, // 0xE4
|
|
|
|
QueryPercent, // 0xE5
|
|
|
|
QueryPercent, // 0xE6
|
|
|
|
QueryPercent, // 0xE7
|
|
|
|
QueryPercent, // 0xE8
|
|
|
|
QueryPercent, // 0xE9
|
|
|
|
QueryPercent, // 0xEA
|
|
|
|
QueryPercent, // 0xEB
|
|
|
|
QueryPercent, // 0xEC
|
|
|
|
QueryPercent, // 0xED
|
|
|
|
QueryPercent, // 0xEE
|
|
|
|
QueryPercent, // 0xEF
|
|
|
|
QueryPercent, // 0xF0
|
|
|
|
QueryPercent, // 0xF1
|
|
|
|
QueryPercent, // 0xF2
|
|
|
|
QueryPercent, // 0xF3
|
|
|
|
QueryPercent, // 0xF4
|
|
|
|
QueryPercent, // 0xF5
|
|
|
|
QueryPercent, // 0xF6
|
|
|
|
QueryPercent, // 0xF7
|
|
|
|
QueryPercent, // 0xF8
|
|
|
|
QueryPercent, // 0xF9
|
|
|
|
QueryPercent, // 0xFA
|
|
|
|
QueryPercent, // 0xFB
|
|
|
|
QueryPercent, // 0xFC
|
|
|
|
QueryPercent, // 0xFD
|
|
|
|
QueryPercent, // 0xFE
|
|
|
|
QueryPercent, // 0xFF
|
|
|
|
};
|
|
|
|
|
2016-09-28 01:23:50 +00:00
|
|
|
template<typename CharacterType> ALWAYS_INLINE static bool isC0Control(CharacterType character) { return character <= 0x1F; }
|
|
|
|
template<typename CharacterType> ALWAYS_INLINE static bool isC0ControlOrSpace(CharacterType character) { return character <= 0x20; }
|
|
|
|
template<typename CharacterType> ALWAYS_INLINE static bool isTabOrNewline(CharacterType character) { return character <= 0xD && character >= 0x9 && character != 0xB && character != 0xC; }
|
|
|
|
template<typename CharacterType> ALWAYS_INLINE static bool isInSimpleEncodeSet(CharacterType character) { return character > 0x7E || isC0Control(character); }
|
2020-09-01 16:42:54 +00:00
|
|
|
template<typename CharacterType> ALWAYS_INLINE static bool isInFragmentEncodeSet(CharacterType character) { return character > 0x7E || character == '`' || ((characterClassTable[character] & QueryPercent) && character != '#'); }
|
2016-09-28 01:23:50 +00:00
|
|
|
template<typename CharacterType> ALWAYS_INLINE static bool isInDefaultEncodeSet(CharacterType character) { return character > 0x7E || characterClassTable[character] & Default; }
|
|
|
|
template<typename CharacterType> ALWAYS_INLINE static bool isInUserInfoEncodeSet(CharacterType character) { return character > 0x7E || characterClassTable[character] & UserInfo; }
|
|
|
|
template<typename CharacterType> ALWAYS_INLINE static bool isPercentOrNonASCII(CharacterType character) { return !isASCII(character) || character == '%'; }
|
|
|
|
template<typename CharacterType> ALWAYS_INLINE static bool isSlashQuestionOrHash(CharacterType character) { return character <= '\\' && characterClassTable[character] & SlashQuestionOrHash; }
|
2016-10-05 18:25:02 +00:00
|
|
|
template<typename CharacterType> ALWAYS_INLINE static bool isValidSchemeCharacter(CharacterType character) { return character <= 'z' && characterClassTable[character] & ValidScheme; }
|
2021-01-26 21:14:33 +00:00
|
|
|
template<typename CharacterType> ALWAYS_INLINE static bool isForbiddenHostCodePoint(CharacterType character) { return character <= '|' && characterClassTable[character] & ForbiddenHost; }
|
2017-07-03 17:20:25 +00:00
|
|
|
ALWAYS_INLINE static bool shouldPercentEncodeQueryByte(uint8_t byte, const bool& urlIsSpecial)
|
|
|
|
{
|
|
|
|
if (characterClassTable[byte] & QueryPercent)
|
|
|
|
return true;
|
|
|
|
if (byte == '\'' && urlIsSpecial)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-20 18:27:37 +00:00
|
|
|
|
2017-11-14 19:15:23 +00:00
|
|
|
bool URLParser::isInUserInfoEncodeSet(UChar c)
|
|
|
|
{
|
2018-12-01 03:28:36 +00:00
|
|
|
return WTF::isInUserInfoEncodeSet(c);
|
2017-11-14 19:15:23 +00:00
|
|
|
}
|
|
|
|
|
2016-09-29 18:18:04 +00:00
|
|
|
template<typename CharacterType, URLParser::ReportSyntaxViolation reportSyntaxViolation>
|
2016-09-28 01:23:50 +00:00
|
|
|
ALWAYS_INLINE void URLParser::advance(CodePointIterator<CharacterType>& iterator, const CodePointIterator<CharacterType>& iteratorForSyntaxViolationPosition)
|
2016-09-20 18:27:37 +00:00
|
|
|
{
|
|
|
|
++iterator;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
while (UNLIKELY(!iterator.atEnd() && isTabOrNewline(*iterator))) {
|
2016-09-29 18:18:04 +00:00
|
|
|
if (reportSyntaxViolation == ReportSyntaxViolation::Yes)
|
|
|
|
syntaxViolation(iteratorForSyntaxViolationPosition);
|
2016-09-20 18:27:37 +00:00
|
|
|
++iterator;
|
2016-09-23 23:40:46 +00:00
|
|
|
}
|
2016-09-20 18:27:37 +00:00
|
|
|
}
|
|
|
|
|
2016-10-03 22:55:46 +00:00
|
|
|
template<typename CharacterType>
|
|
|
|
bool URLParser::takesTwoAdvancesUntilEnd(CodePointIterator<CharacterType> iterator)
|
|
|
|
{
|
|
|
|
if (iterator.atEnd())
|
|
|
|
return false;
|
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(iterator);
|
|
|
|
if (iterator.atEnd())
|
|
|
|
return false;
|
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(iterator);
|
|
|
|
return iterator.atEnd();
|
|
|
|
}
|
|
|
|
|
2016-09-23 19:57:57 +00:00
|
|
|
template<typename CharacterType>
|
2016-09-28 01:23:50 +00:00
|
|
|
ALWAYS_INLINE bool URLParser::isWindowsDriveLetter(CodePointIterator<CharacterType> iterator)
|
2016-09-03 00:32:49 +00:00
|
|
|
{
|
2020-10-05 14:43:04 +00:00
|
|
|
// https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
|
2016-09-15 18:12:09 +00:00
|
|
|
if (iterator.atEnd() || !isASCIIAlpha(*iterator))
|
2016-09-03 00:32:49 +00:00
|
|
|
return false;
|
2016-09-29 18:18:04 +00:00
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(iterator);
|
2016-09-15 18:12:09 +00:00
|
|
|
if (iterator.atEnd())
|
2016-09-03 00:32:49 +00:00
|
|
|
return false;
|
2020-10-05 14:43:04 +00:00
|
|
|
if (*iterator != ':' && *iterator != '|')
|
|
|
|
return false;
|
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(iterator);
|
|
|
|
return iterator.atEnd() || *iterator == '/' || *iterator == '\\' || *iterator == '?' || *iterator == '#';
|
2016-09-03 00:32:49 +00:00
|
|
|
}
|
|
|
|
|
2016-09-28 01:23:50 +00:00
|
|
|
ALWAYS_INLINE void URLParser::appendToASCIIBuffer(UChar32 codePoint)
|
2016-09-23 22:32:28 +00:00
|
|
|
{
|
|
|
|
ASSERT(isASCII(codePoint));
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (UNLIKELY(m_didSeeSyntaxViolation))
|
2016-09-23 23:40:46 +00:00
|
|
|
m_asciiBuffer.append(codePoint);
|
2016-09-23 22:32:28 +00:00
|
|
|
}
|
|
|
|
|
2016-09-28 01:23:50 +00:00
|
|
|
ALWAYS_INLINE void URLParser::appendToASCIIBuffer(const char* characters, size_t length)
|
2016-09-23 22:32:28 +00:00
|
|
|
{
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (UNLIKELY(m_didSeeSyntaxViolation))
|
2016-09-23 23:40:46 +00:00
|
|
|
m_asciiBuffer.append(characters, length);
|
2016-09-23 22:32:28 +00:00
|
|
|
}
|
|
|
|
|
2016-09-23 19:57:57 +00:00
|
|
|
template<typename CharacterType>
|
2016-09-28 00:31:44 +00:00
|
|
|
void URLParser::appendWindowsDriveLetter(CodePointIterator<CharacterType>& iterator)
|
2016-09-20 18:27:37 +00:00
|
|
|
{
|
2020-10-05 14:43:04 +00:00
|
|
|
auto lengthWithOnlyOneSlashInPath = m_url.m_hostEnd + m_url.m_portLength + 1;
|
|
|
|
if (m_url.m_pathAfterLastSlash > lengthWithOnlyOneSlashInPath) {
|
|
|
|
syntaxViolation(iterator);
|
|
|
|
m_url.m_pathAfterLastSlash = lengthWithOnlyOneSlashInPath;
|
|
|
|
m_asciiBuffer.resize(lengthWithOnlyOneSlashInPath);
|
|
|
|
}
|
2016-09-28 00:31:44 +00:00
|
|
|
ASSERT(isWindowsDriveLetter(iterator));
|
|
|
|
appendToASCIIBuffer(*iterator);
|
|
|
|
advance(iterator);
|
|
|
|
ASSERT(!iterator.atEnd());
|
|
|
|
ASSERT(*iterator == ':' || *iterator == '|');
|
2016-09-29 18:18:04 +00:00
|
|
|
if (*iterator == '|')
|
|
|
|
syntaxViolation(iterator);
|
2016-09-28 00:31:44 +00:00
|
|
|
appendToASCIIBuffer(':');
|
|
|
|
advance(iterator);
|
2016-09-20 18:27:37 +00:00
|
|
|
}
|
|
|
|
|
2017-03-06 22:55:33 +00:00
|
|
|
bool URLParser::copyBaseWindowsDriveLetter(const URL& base)
|
|
|
|
{
|
|
|
|
if (base.protocolIs("file")) {
|
2018-07-13 00:28:36 +00:00
|
|
|
RELEASE_ASSERT(base.m_hostEnd + base.m_portLength < base.m_string.length());
|
2017-03-06 22:55:33 +00:00
|
|
|
if (base.m_string.is8Bit()) {
|
|
|
|
const LChar* begin = base.m_string.characters8();
|
2018-07-13 00:28:36 +00:00
|
|
|
CodePointIterator<LChar> c(begin + base.m_hostEnd + base.m_portLength + 1, begin + base.m_string.length());
|
2017-03-06 22:55:33 +00:00
|
|
|
if (isWindowsDriveLetter(c)) {
|
|
|
|
appendWindowsDriveLetter(c);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
const UChar* begin = base.m_string.characters16();
|
2018-07-13 00:28:36 +00:00
|
|
|
CodePointIterator<UChar> c(begin + base.m_hostEnd + base.m_portLength + 1, begin + base.m_string.length());
|
2017-03-06 22:55:33 +00:00
|
|
|
if (isWindowsDriveLetter(c)) {
|
|
|
|
appendWindowsDriveLetter(c);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-09-23 19:57:57 +00:00
|
|
|
template<typename CharacterType>
|
2016-09-23 20:58:03 +00:00
|
|
|
bool URLParser::shouldCopyFileURL(CodePointIterator<CharacterType> iterator)
|
2016-09-03 00:32:49 +00:00
|
|
|
{
|
2016-09-23 19:57:57 +00:00
|
|
|
if (!isWindowsDriveLetter(iterator))
|
2016-09-03 00:32:49 +00:00
|
|
|
return true;
|
2016-09-15 18:12:09 +00:00
|
|
|
if (iterator.atEnd())
|
2016-09-03 00:32:49 +00:00
|
|
|
return false;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(iterator);
|
2016-09-15 18:12:09 +00:00
|
|
|
if (iterator.atEnd())
|
2016-09-03 00:32:49 +00:00
|
|
|
return true;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(iterator);
|
2016-09-15 18:12:09 +00:00
|
|
|
if (iterator.atEnd())
|
2016-09-06 18:16:07 +00:00
|
|
|
return true;
|
2016-09-15 18:48:45 +00:00
|
|
|
return !isSlashQuestionOrHash(*iterator);
|
2016-09-06 18:16:07 +00:00
|
|
|
}
|
|
|
|
|
2018-05-04 00:40:18 +00:00
|
|
|
static void percentEncodeByte(uint8_t byte, Vector<LChar>& buffer)
|
2016-09-06 18:16:07 +00:00
|
|
|
{
|
2016-09-16 20:35:16 +00:00
|
|
|
buffer.append('%');
|
|
|
|
buffer.append(upperNibbleToASCIIHexDigit(byte));
|
|
|
|
buffer.append(lowerNibbleToASCIIHexDigit(byte));
|
2016-09-06 18:16:07 +00:00
|
|
|
}
|
|
|
|
|
2016-09-23 22:32:28 +00:00
|
|
|
void URLParser::percentEncodeByte(uint8_t byte)
|
|
|
|
{
|
2016-09-30 18:46:28 +00:00
|
|
|
ASSERT(m_didSeeSyntaxViolation);
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('%');
|
|
|
|
appendToASCIIBuffer(upperNibbleToASCIIHexDigit(byte));
|
|
|
|
appendToASCIIBuffer(lowerNibbleToASCIIHexDigit(byte));
|
|
|
|
}
|
|
|
|
|
|
|
|
const char replacementCharacterUTF8PercentEncoded[10] = "%EF%BF%BD";
|
|
|
|
const size_t replacementCharacterUTF8PercentEncodedLength = sizeof(replacementCharacterUTF8PercentEncoded) - 1;
|
2016-09-21 06:34:13 +00:00
|
|
|
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
template<bool(*isInCodeSet)(UChar32), typename CharacterType>
|
2016-09-28 01:23:50 +00:00
|
|
|
ALWAYS_INLINE void URLParser::utf8PercentEncode(const CodePointIterator<CharacterType>& iterator)
|
2016-09-06 18:16:07 +00:00
|
|
|
{
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
ASSERT(!iterator.atEnd());
|
|
|
|
UChar32 codePoint = *iterator;
|
|
|
|
if (LIKELY(isASCII(codePoint))) {
|
|
|
|
if (UNLIKELY(isInCodeSet(codePoint))) {
|
|
|
|
syntaxViolation(iterator);
|
2016-09-23 22:32:28 +00:00
|
|
|
percentEncodeByte(codePoint);
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
} else
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer(codePoint);
|
2016-09-23 19:57:57 +00:00
|
|
|
return;
|
2016-09-16 20:35:16 +00:00
|
|
|
}
|
2016-09-23 19:57:57 +00:00
|
|
|
ASSERT_WITH_MESSAGE(isInCodeSet(codePoint), "isInCodeSet should always return true for non-ASCII characters");
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(iterator);
|
2020-10-05 14:40:55 +00:00
|
|
|
|
|
|
|
uint8_t buffer[U8_MAX_LENGTH];
|
|
|
|
int32_t offset = 0;
|
|
|
|
UBool isError = false;
|
|
|
|
U8_APPEND(buffer, offset, U8_MAX_LENGTH, codePoint, isError);
|
|
|
|
if (isError) {
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer(replacementCharacterUTF8PercentEncoded, replacementCharacterUTF8PercentEncodedLength);
|
2016-09-23 19:57:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int32_t i = 0; i < offset; ++i)
|
2016-09-23 22:32:28 +00:00
|
|
|
percentEncodeByte(buffer[i]);
|
2016-09-06 18:16:07 +00:00
|
|
|
}
|
|
|
|
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
template<typename CharacterType>
|
2016-09-28 01:23:50 +00:00
|
|
|
ALWAYS_INLINE void URLParser::utf8QueryEncode(const CodePointIterator<CharacterType>& iterator)
|
2016-09-14 18:16:29 +00:00
|
|
|
{
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
ASSERT(!iterator.atEnd());
|
|
|
|
UChar32 codePoint = *iterator;
|
|
|
|
if (LIKELY(isASCII(codePoint))) {
|
2017-07-03 17:20:25 +00:00
|
|
|
if (UNLIKELY(shouldPercentEncodeQueryByte(codePoint, m_urlIsSpecial))) {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(iterator);
|
2016-09-23 22:32:28 +00:00
|
|
|
percentEncodeByte(codePoint);
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
} else
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer(codePoint);
|
2016-09-23 19:57:57 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-10-05 14:40:55 +00:00
|
|
|
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(iterator);
|
2016-09-21 06:34:13 +00:00
|
|
|
|
2016-09-23 19:57:57 +00:00
|
|
|
uint8_t buffer[U8_MAX_LENGTH];
|
|
|
|
int32_t offset = 0;
|
2020-10-05 14:40:55 +00:00
|
|
|
UBool isError = false;
|
|
|
|
U8_APPEND(buffer, offset, U8_MAX_LENGTH, codePoint, isError);
|
|
|
|
if (isError) {
|
|
|
|
appendToASCIIBuffer(replacementCharacterUTF8PercentEncoded, replacementCharacterUTF8PercentEncodedLength);
|
|
|
|
return;
|
|
|
|
}
|
2016-09-23 19:57:57 +00:00
|
|
|
for (int32_t i = 0; i < offset; ++i) {
|
|
|
|
auto byte = buffer[i];
|
2017-07-03 17:20:25 +00:00
|
|
|
if (shouldPercentEncodeQueryByte(byte, m_urlIsSpecial))
|
2016-09-23 22:32:28 +00:00
|
|
|
percentEncodeByte(byte);
|
2016-09-23 19:57:57 +00:00
|
|
|
else
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer(byte);
|
2016-09-14 18:16:29 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-30 18:46:28 +00:00
|
|
|
|
|
|
|
template<typename CharacterType>
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
void URLParser::encodeNonUTF8Query(const Vector<UChar>& source, const URLTextEncoding& encoding, CodePointIterator<CharacterType> iterator)
|
2016-09-06 18:16:07 +00:00
|
|
|
{
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
auto encoded = encoding.encodeForURLParsing(StringView(source.data(), source.size()));
|
2017-12-07 04:06:53 +00:00
|
|
|
auto* data = encoded.data();
|
|
|
|
size_t length = encoded.size();
|
2016-09-30 18:46:28 +00:00
|
|
|
|
|
|
|
if (!length == !iterator.atEnd()) {
|
|
|
|
syntaxViolation(iterator);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t i = 0;
|
|
|
|
for (; i < length; ++i) {
|
|
|
|
ASSERT(!iterator.atEnd());
|
|
|
|
uint8_t byte = data[i];
|
|
|
|
if (UNLIKELY(byte != *iterator)) {
|
|
|
|
syntaxViolation(iterator);
|
|
|
|
break;
|
|
|
|
}
|
2017-07-03 17:20:25 +00:00
|
|
|
if (UNLIKELY(shouldPercentEncodeQueryByte(byte, m_urlIsSpecial))) {
|
2016-09-30 18:46:28 +00:00
|
|
|
syntaxViolation(iterator);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
appendToASCIIBuffer(byte);
|
|
|
|
++iterator;
|
|
|
|
}
|
2016-10-06 20:47:44 +00:00
|
|
|
while (!iterator.atEnd() && isTabOrNewline(*iterator))
|
|
|
|
++iterator;
|
2016-09-30 18:46:28 +00:00
|
|
|
ASSERT((i == length) == iterator.atEnd());
|
|
|
|
for (; i < length; ++i) {
|
|
|
|
ASSERT(m_didSeeSyntaxViolation);
|
2016-09-06 18:16:07 +00:00
|
|
|
uint8_t byte = data[i];
|
2017-07-03 17:20:25 +00:00
|
|
|
if (shouldPercentEncodeQueryByte(byte, m_urlIsSpecial))
|
2016-09-23 22:32:28 +00:00
|
|
|
percentEncodeByte(byte);
|
2016-09-06 18:16:07 +00:00
|
|
|
else
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer(byte);
|
2016-09-06 18:16:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<uint16_t> URLParser::defaultPortForProtocol(StringView scheme)
|
2016-09-06 18:16:07 +00:00
|
|
|
{
|
2019-09-18 00:36:19 +00:00
|
|
|
static constexpr uint16_t ftpPort = 21;
|
|
|
|
static constexpr uint16_t httpPort = 80;
|
|
|
|
static constexpr uint16_t httpsPort = 443;
|
|
|
|
static constexpr uint16_t wsPort = 80;
|
|
|
|
static constexpr uint16_t wssPort = 443;
|
2016-09-12 18:06:59 +00:00
|
|
|
|
|
|
|
auto length = scheme.length();
|
|
|
|
if (!length)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-09-12 18:06:59 +00:00
|
|
|
switch (scheme[0]) {
|
|
|
|
case 'w':
|
|
|
|
switch (length) {
|
|
|
|
case 2:
|
2016-10-24 18:25:40 +00:00
|
|
|
if (scheme[1] == 's')
|
|
|
|
return wsPort;
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-09-12 18:06:59 +00:00
|
|
|
case 3:
|
2016-10-24 18:25:40 +00:00
|
|
|
if (scheme[1] == 's'
|
|
|
|
&& scheme[2] == 's')
|
|
|
|
return wssPort;
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-09-12 18:06:59 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case 'h':
|
|
|
|
switch (length) {
|
|
|
|
case 4:
|
2016-10-24 18:25:40 +00:00
|
|
|
if (scheme[1] == 't'
|
2016-09-12 18:06:59 +00:00
|
|
|
&& scheme[2] == 't'
|
2016-10-24 18:25:40 +00:00
|
|
|
&& scheme[3] == 'p')
|
|
|
|
return httpPort;
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-09-12 18:06:59 +00:00
|
|
|
case 5:
|
2016-10-24 18:25:40 +00:00
|
|
|
if (scheme[1] == 't'
|
2016-09-12 18:06:59 +00:00
|
|
|
&& scheme[2] == 't'
|
|
|
|
&& scheme[3] == 'p'
|
2016-10-24 18:25:40 +00:00
|
|
|
&& scheme[4] == 's')
|
|
|
|
return httpsPort;
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-09-12 18:06:59 +00:00
|
|
|
default:
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-09-12 18:06:59 +00:00
|
|
|
}
|
|
|
|
case 'f':
|
2016-10-24 18:25:40 +00:00
|
|
|
if (length == 3
|
2016-09-12 18:06:59 +00:00
|
|
|
&& scheme[1] == 't'
|
2016-10-24 18:25:40 +00:00
|
|
|
&& scheme[2] == 'p')
|
|
|
|
return ftpPort;
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-09-12 18:06:59 +00:00
|
|
|
default:
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-09-12 18:06:59 +00:00
|
|
|
}
|
2016-09-03 00:32:49 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 18:25:02 +00:00
|
|
|
enum class Scheme {
|
|
|
|
WS,
|
|
|
|
WSS,
|
|
|
|
File,
|
|
|
|
FTP,
|
|
|
|
HTTP,
|
|
|
|
HTTPS,
|
|
|
|
NonSpecial
|
|
|
|
};
|
|
|
|
|
|
|
|
ALWAYS_INLINE static Scheme scheme(StringView scheme)
|
2016-08-12 20:03:49 +00:00
|
|
|
{
|
2016-09-12 18:06:59 +00:00
|
|
|
auto length = scheme.length();
|
|
|
|
if (!length)
|
2016-10-05 18:25:02 +00:00
|
|
|
return Scheme::NonSpecial;
|
2016-09-12 18:06:59 +00:00
|
|
|
switch (scheme[0]) {
|
|
|
|
case 'f':
|
|
|
|
switch (length) {
|
|
|
|
case 3:
|
2016-10-05 18:25:02 +00:00
|
|
|
if (scheme[1] == 't'
|
|
|
|
&& scheme[2] == 'p')
|
|
|
|
return Scheme::FTP;
|
|
|
|
return Scheme::NonSpecial;
|
2016-09-12 18:06:59 +00:00
|
|
|
case 4:
|
2016-10-05 18:25:02 +00:00
|
|
|
if (scheme[1] == 'i'
|
2016-09-12 18:06:59 +00:00
|
|
|
&& scheme[2] == 'l'
|
2016-10-05 18:25:02 +00:00
|
|
|
&& scheme[3] == 'e')
|
|
|
|
return Scheme::File;
|
|
|
|
return Scheme::NonSpecial;
|
2016-09-12 18:06:59 +00:00
|
|
|
default:
|
2016-10-05 18:25:02 +00:00
|
|
|
return Scheme::NonSpecial;
|
2016-09-12 18:06:59 +00:00
|
|
|
}
|
|
|
|
case 'h':
|
|
|
|
switch (length) {
|
|
|
|
case 4:
|
2016-10-05 18:25:02 +00:00
|
|
|
if (scheme[1] == 't'
|
2016-09-12 18:06:59 +00:00
|
|
|
&& scheme[2] == 't'
|
2016-10-05 18:25:02 +00:00
|
|
|
&& scheme[3] == 'p')
|
|
|
|
return Scheme::HTTP;
|
|
|
|
return Scheme::NonSpecial;
|
2016-09-12 18:06:59 +00:00
|
|
|
case 5:
|
2016-10-05 18:25:02 +00:00
|
|
|
if (scheme[1] == 't'
|
2016-09-12 18:06:59 +00:00
|
|
|
&& scheme[2] == 't'
|
|
|
|
&& scheme[3] == 'p'
|
2016-10-05 18:25:02 +00:00
|
|
|
&& scheme[4] == 's')
|
|
|
|
return Scheme::HTTPS;
|
|
|
|
return Scheme::NonSpecial;
|
2016-09-12 18:06:59 +00:00
|
|
|
default:
|
2016-10-05 18:25:02 +00:00
|
|
|
return Scheme::NonSpecial;
|
2016-09-12 18:06:59 +00:00
|
|
|
}
|
|
|
|
case 'w':
|
|
|
|
switch (length) {
|
|
|
|
case 2:
|
2016-10-05 18:25:02 +00:00
|
|
|
if (scheme[1] == 's')
|
|
|
|
return Scheme::WS;
|
|
|
|
return Scheme::NonSpecial;
|
2016-09-12 18:06:59 +00:00
|
|
|
case 3:
|
2016-10-05 18:25:02 +00:00
|
|
|
if (scheme[1] == 's'
|
|
|
|
&& scheme[2] == 's')
|
|
|
|
return Scheme::WSS;
|
|
|
|
return Scheme::NonSpecial;
|
2016-09-12 18:06:59 +00:00
|
|
|
default:
|
2016-10-05 18:25:02 +00:00
|
|
|
return Scheme::NonSpecial;
|
2016-09-12 18:06:59 +00:00
|
|
|
}
|
|
|
|
default:
|
2016-10-05 18:25:02 +00:00
|
|
|
return Scheme::NonSpecial;
|
2016-09-12 18:06:59 +00:00
|
|
|
}
|
2016-08-12 20:03:49 +00:00
|
|
|
}
|
|
|
|
|
2021-06-09 20:46:24 +00:00
|
|
|
std::optional<String> URLParser::maybeCanonicalizeScheme(StringView scheme)
|
2017-03-10 00:38:20 +00:00
|
|
|
{
|
|
|
|
if (scheme.isEmpty())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-03-10 00:38:20 +00:00
|
|
|
|
|
|
|
if (!isASCIIAlpha(scheme[0]))
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-03-10 00:38:20 +00:00
|
|
|
|
|
|
|
for (size_t i = 1; i < scheme.length(); ++i) {
|
|
|
|
if (isASCIIAlphanumeric(scheme[i]) || scheme[i] == '+' || scheme[i] == '-' || scheme[i] == '.')
|
|
|
|
continue;
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-03-10 00:38:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return scheme.convertToASCIILowercase();
|
|
|
|
}
|
|
|
|
|
2021-07-08 22:59:59 +00:00
|
|
|
bool URLParser::isSpecialScheme(StringView schemeArg)
|
2017-03-10 00:38:20 +00:00
|
|
|
{
|
|
|
|
return scheme(schemeArg) != Scheme::NonSpecial;
|
|
|
|
}
|
|
|
|
|
2016-08-28 05:55:17 +00:00
|
|
|
enum class URLParser::URLPart {
|
|
|
|
SchemeEnd,
|
|
|
|
UserStart,
|
|
|
|
UserEnd,
|
|
|
|
PasswordEnd,
|
|
|
|
HostEnd,
|
|
|
|
PortEnd,
|
|
|
|
PathAfterLastSlash,
|
|
|
|
PathEnd,
|
|
|
|
QueryEnd,
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t URLParser::urlLengthUntilPart(const URL& url, URLPart part)
|
|
|
|
{
|
|
|
|
switch (part) {
|
|
|
|
case URLPart::QueryEnd:
|
|
|
|
return url.m_queryEnd;
|
|
|
|
case URLPart::PathEnd:
|
|
|
|
return url.m_pathEnd;
|
|
|
|
case URLPart::PathAfterLastSlash:
|
|
|
|
return url.m_pathAfterLastSlash;
|
|
|
|
case URLPart::PortEnd:
|
2018-07-13 00:28:36 +00:00
|
|
|
return url.m_hostEnd + url.m_portLength;
|
2016-08-28 05:55:17 +00:00
|
|
|
case URLPart::HostEnd:
|
|
|
|
return url.m_hostEnd;
|
|
|
|
case URLPart::PasswordEnd:
|
|
|
|
return url.m_passwordEnd;
|
|
|
|
case URLPart::UserEnd:
|
|
|
|
return url.m_userEnd;
|
|
|
|
case URLPart::UserStart:
|
|
|
|
return url.m_userStart;
|
|
|
|
case URLPart::SchemeEnd:
|
|
|
|
return url.m_schemeEnd;
|
|
|
|
}
|
|
|
|
ASSERT_NOT_REACHED();
|
|
|
|
return 0;
|
|
|
|
}
|
2016-09-16 20:35:16 +00:00
|
|
|
|
2016-10-03 17:28:04 +00:00
|
|
|
void URLParser::copyASCIIStringUntil(const String& string, size_t length)
|
2016-09-16 20:35:16 +00:00
|
|
|
{
|
2016-10-03 17:28:04 +00:00
|
|
|
RELEASE_ASSERT(length <= string.length());
|
|
|
|
if (string.isNull())
|
2016-09-21 20:19:07 +00:00
|
|
|
return;
|
2016-09-23 22:32:28 +00:00
|
|
|
ASSERT(m_asciiBuffer.isEmpty());
|
2017-03-06 22:55:33 +00:00
|
|
|
if (string.is8Bit())
|
2016-10-03 17:28:04 +00:00
|
|
|
appendToASCIIBuffer(string.characters8(), length);
|
2017-03-06 22:55:33 +00:00
|
|
|
else {
|
2016-09-16 20:35:16 +00:00
|
|
|
const UChar* characters = string.characters16();
|
2016-10-03 17:28:04 +00:00
|
|
|
for (size_t i = 0; i < length; ++i) {
|
2016-09-16 20:35:16 +00:00
|
|
|
UChar c = characters[i];
|
|
|
|
ASSERT_WITH_SECURITY_IMPLICATION(isASCII(c));
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer(c);
|
2016-09-16 20:35:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
template<typename CharacterType>
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
void URLParser::copyURLPartsUntil(const URL& base, URLPart part, const CodePointIterator<CharacterType>& iterator, const URLTextEncoding*& nonUTF8QueryEncoding)
|
2016-08-28 05:55:17 +00:00
|
|
|
{
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(iterator);
|
|
|
|
|
2016-09-16 20:35:16 +00:00
|
|
|
m_asciiBuffer.clear();
|
2016-10-03 17:28:04 +00:00
|
|
|
copyASCIIStringUntil(base.m_string, urlLengthUntilPart(base, part));
|
2016-08-28 05:55:17 +00:00
|
|
|
switch (part) {
|
|
|
|
case URLPart::QueryEnd:
|
|
|
|
m_url.m_queryEnd = base.m_queryEnd;
|
|
|
|
FALLTHROUGH;
|
|
|
|
case URLPart::PathEnd:
|
|
|
|
m_url.m_pathEnd = base.m_pathEnd;
|
|
|
|
FALLTHROUGH;
|
|
|
|
case URLPart::PathAfterLastSlash:
|
|
|
|
m_url.m_pathAfterLastSlash = base.m_pathAfterLastSlash;
|
|
|
|
FALLTHROUGH;
|
|
|
|
case URLPart::PortEnd:
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = base.m_portLength;
|
2016-08-28 05:55:17 +00:00
|
|
|
FALLTHROUGH;
|
|
|
|
case URLPart::HostEnd:
|
|
|
|
m_url.m_hostEnd = base.m_hostEnd;
|
|
|
|
FALLTHROUGH;
|
|
|
|
case URLPart::PasswordEnd:
|
|
|
|
m_url.m_passwordEnd = base.m_passwordEnd;
|
|
|
|
FALLTHROUGH;
|
|
|
|
case URLPart::UserEnd:
|
|
|
|
m_url.m_userEnd = base.m_userEnd;
|
|
|
|
FALLTHROUGH;
|
|
|
|
case URLPart::UserStart:
|
|
|
|
m_url.m_userStart = base.m_userStart;
|
|
|
|
FALLTHROUGH;
|
|
|
|
case URLPart::SchemeEnd:
|
|
|
|
m_url.m_isValid = base.m_isValid;
|
|
|
|
m_url.m_protocolIsInHTTPFamily = base.m_protocolIsInHTTPFamily;
|
|
|
|
m_url.m_schemeEnd = base.m_schemeEnd;
|
|
|
|
}
|
Non-special URLs are not idempotent
https://bugs.webkit.org/show_bug.cgi?id=215762
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/url-constructor-expected.txt:
* web-platform-tests/url/url-setters-expected.txt:
Source/WTF:
https://github.com/whatwg/url/pull/505 added an interesting edge case to the URL serialization:
"If url’s host is null, url’s path’s size is greater than 1, and url’s path[0] is the empty string, then append U+002F (/) followed by U+002E (.) to output."
The problem was that URLs like "a:/a/..//a" would be parsed into "a://a" with a pathname of "//a" and an empty host. If "a://a" was then reparsed, it would again have an href of "a://a"
but its host would be "a" and it would have an empty path. There is consensus that URL parsing should be idempotent, so we need to do something different here.
According to https://github.com/whatwg/url/issues/415#issuecomment-419197290 this follows what Edge did (and then subsequently abandoned when they switched to Chromium)
to make URL parsing idempotent by adding "/." before the path in the edge case of a URL with a non-special scheme (not http, https, wss, etc.) and a null host and a non-empty path that
has an empty first segment. All the members of the URL remain unchanged except the full serialization (href). This is not important in practice, but important in theory.
Our URL parser tries very hard to use the exact same WTF::String object given as input if it can. However, this step is better implemented as a post-processing step that will almost never happen
because otherwise we would have to parse the entire path twice to find out if we need to add "./" or if the "./" that may have already been there needs to stay. This is illustrated with the test URL
"t:/.//p/../../../..//x" which does need the "./".
In the common case, this adds one well-predicted branch to URL parsing, so I expect performance to be unaffected. Since this is such a rare edge case of URLs, I expect no compatibility problems.
* wtf/URL.cpp:
(WTF::URL::pathStart const):
* wtf/URL.h:
(WTF::URL::pathStart const): Deleted.
* wtf/URLParser.cpp:
(WTF::URLParser::copyURLPartsUntil):
(WTF::URLParser::URLParser):
(WTF::URLParser::needsNonSpecialDotSlash const):
(WTF::URLParser::addNonSpecialDotSlash):
* wtf/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WTF/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/229956@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267837 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-01 17:05:41 +00:00
|
|
|
|
2016-10-06 23:05:17 +00:00
|
|
|
switch (scheme(StringView(m_asciiBuffer.data(), m_url.m_schemeEnd))) {
|
|
|
|
case Scheme::WS:
|
|
|
|
case Scheme::WSS:
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
nonUTF8QueryEncoding = nullptr;
|
2017-02-24 16:45:32 +00:00
|
|
|
m_urlIsSpecial = true;
|
|
|
|
return;
|
2016-10-06 23:05:17 +00:00
|
|
|
case Scheme::File:
|
2017-02-24 16:45:32 +00:00
|
|
|
m_urlIsFile = true;
|
|
|
|
FALLTHROUGH;
|
2016-10-06 23:05:17 +00:00
|
|
|
case Scheme::FTP:
|
|
|
|
case Scheme::HTTP:
|
|
|
|
case Scheme::HTTPS:
|
|
|
|
m_urlIsSpecial = true;
|
|
|
|
return;
|
|
|
|
case Scheme::NonSpecial:
|
|
|
|
m_urlIsSpecial = false;
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
nonUTF8QueryEncoding = nullptr;
|
Non-special URLs are not idempotent
https://bugs.webkit.org/show_bug.cgi?id=215762
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/url-constructor-expected.txt:
* web-platform-tests/url/url-setters-expected.txt:
Source/WTF:
https://github.com/whatwg/url/pull/505 added an interesting edge case to the URL serialization:
"If url’s host is null, url’s path’s size is greater than 1, and url’s path[0] is the empty string, then append U+002F (/) followed by U+002E (.) to output."
The problem was that URLs like "a:/a/..//a" would be parsed into "a://a" with a pathname of "//a" and an empty host. If "a://a" was then reparsed, it would again have an href of "a://a"
but its host would be "a" and it would have an empty path. There is consensus that URL parsing should be idempotent, so we need to do something different here.
According to https://github.com/whatwg/url/issues/415#issuecomment-419197290 this follows what Edge did (and then subsequently abandoned when they switched to Chromium)
to make URL parsing idempotent by adding "/." before the path in the edge case of a URL with a non-special scheme (not http, https, wss, etc.) and a null host and a non-empty path that
has an empty first segment. All the members of the URL remain unchanged except the full serialization (href). This is not important in practice, but important in theory.
Our URL parser tries very hard to use the exact same WTF::String object given as input if it can. However, this step is better implemented as a post-processing step that will almost never happen
because otherwise we would have to parse the entire path twice to find out if we need to add "./" or if the "./" that may have already been there needs to stay. This is illustrated with the test URL
"t:/.//p/../../../..//x" which does need the "./".
In the common case, this adds one well-predicted branch to URL parsing, so I expect performance to be unaffected. Since this is such a rare edge case of URLs, I expect no compatibility problems.
* wtf/URL.cpp:
(WTF::URL::pathStart const):
* wtf/URL.h:
(WTF::URL::pathStart const): Deleted.
* wtf/URLParser.cpp:
(WTF::URLParser::copyURLPartsUntil):
(WTF::URLParser::URLParser):
(WTF::URLParser::needsNonSpecialDotSlash const):
(WTF::URLParser::addNonSpecialDotSlash):
* wtf/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WTF/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/229956@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267837 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-01 17:05:41 +00:00
|
|
|
auto pathStart = m_url.m_hostEnd + m_url.m_portLength;
|
|
|
|
if (pathStart + 2 < m_asciiBuffer.size()
|
|
|
|
&& m_asciiBuffer[pathStart] == '/'
|
|
|
|
&& m_asciiBuffer[pathStart + 1] == '.'
|
|
|
|
&& m_asciiBuffer[pathStart + 2] == '/') {
|
|
|
|
m_asciiBuffer.remove(pathStart + 1, 2);
|
|
|
|
m_url.m_pathAfterLastSlash = std::max(2u, m_url.m_pathAfterLastSlash) - 2;
|
|
|
|
m_url.m_pathEnd = std::max(2u, m_url.m_pathEnd) - 2;
|
|
|
|
m_url.m_queryEnd = std::max(2u, m_url.m_queryEnd) - 2;
|
|
|
|
}
|
2016-10-06 23:05:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ASSERT_NOT_REACHED();
|
2016-08-28 05:55:17 +00:00
|
|
|
}
|
2016-09-01 20:33:31 +00:00
|
|
|
|
2016-10-29 00:20:38 +00:00
|
|
|
static const char dotASCIICode[2] = {'2', 'e'};
|
|
|
|
|
2016-09-15 18:12:09 +00:00
|
|
|
template<typename CharacterType>
|
2016-09-29 18:18:04 +00:00
|
|
|
ALWAYS_INLINE bool URLParser::isSingleDotPathSegment(CodePointIterator<CharacterType> c)
|
2016-09-01 20:33:31 +00:00
|
|
|
{
|
2016-09-15 18:12:09 +00:00
|
|
|
if (c.atEnd())
|
2016-09-01 20:33:31 +00:00
|
|
|
return false;
|
|
|
|
if (*c == '.') {
|
2016-09-29 18:18:04 +00:00
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(c);
|
2016-09-15 18:48:45 +00:00
|
|
|
return c.atEnd() || isSlashQuestionOrHash(*c);
|
2016-09-01 20:33:31 +00:00
|
|
|
}
|
2016-10-29 00:20:38 +00:00
|
|
|
if (*c != '%')
|
|
|
|
return false;
|
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(c);
|
|
|
|
if (c.atEnd() || *c != dotASCIICode[0])
|
|
|
|
return false;
|
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(c);
|
|
|
|
if (c.atEnd())
|
|
|
|
return false;
|
|
|
|
if (toASCIILower(*c) == dotASCIICode[1]) {
|
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(c);
|
|
|
|
return c.atEnd() || isSlashQuestionOrHash(*c);
|
|
|
|
}
|
2016-09-01 20:33:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-09-15 18:12:09 +00:00
|
|
|
|
|
|
|
template<typename CharacterType>
|
2016-09-29 18:18:04 +00:00
|
|
|
ALWAYS_INLINE bool URLParser::isDoubleDotPathSegment(CodePointIterator<CharacterType> c)
|
2016-09-01 20:33:31 +00:00
|
|
|
{
|
2016-09-15 18:12:09 +00:00
|
|
|
if (c.atEnd())
|
2016-09-01 20:33:31 +00:00
|
|
|
return false;
|
|
|
|
if (*c == '.') {
|
2016-09-29 18:18:04 +00:00
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(c);
|
2016-09-15 18:12:09 +00:00
|
|
|
return isSingleDotPathSegment(c);
|
2016-09-01 20:33:31 +00:00
|
|
|
}
|
2016-10-29 00:20:38 +00:00
|
|
|
if (*c != '%')
|
|
|
|
return false;
|
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(c);
|
|
|
|
if (c.atEnd() || *c != dotASCIICode[0])
|
|
|
|
return false;
|
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(c);
|
|
|
|
if (c.atEnd())
|
|
|
|
return false;
|
|
|
|
if (toASCIILower(*c) == dotASCIICode[1]) {
|
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(c);
|
|
|
|
return isSingleDotPathSegment(c);
|
|
|
|
}
|
2016-09-01 20:33:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-09-15 18:12:09 +00:00
|
|
|
template<typename CharacterType>
|
2016-09-29 18:18:04 +00:00
|
|
|
void URLParser::consumeSingleDotPathSegment(CodePointIterator<CharacterType>& c)
|
2016-09-01 20:33:31 +00:00
|
|
|
{
|
2016-09-15 18:12:09 +00:00
|
|
|
ASSERT(isSingleDotPathSegment(c));
|
2016-10-29 00:20:38 +00:00
|
|
|
if (*c == '.') {
|
|
|
|
advance(c);
|
|
|
|
if (!c.atEnd()) {
|
|
|
|
if (*c == '/' || *c == '\\')
|
|
|
|
advance(c);
|
|
|
|
else
|
|
|
|
ASSERT(*c == '?' || *c == '#');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ASSERT(*c == '%');
|
|
|
|
advance(c);
|
|
|
|
ASSERT(*c == dotASCIICode[0]);
|
|
|
|
advance(c);
|
|
|
|
ASSERT(toASCIILower(*c) == dotASCIICode[1]);
|
|
|
|
advance(c);
|
|
|
|
if (!c.atEnd()) {
|
|
|
|
if (*c == '/' || *c == '\\')
|
|
|
|
advance(c);
|
|
|
|
else
|
|
|
|
ASSERT(*c == '?' || *c == '#');
|
|
|
|
}
|
2016-09-01 20:33:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-15 18:12:09 +00:00
|
|
|
template<typename CharacterType>
|
2016-09-29 18:18:04 +00:00
|
|
|
void URLParser::consumeDoubleDotPathSegment(CodePointIterator<CharacterType>& c)
|
2016-09-01 20:33:31 +00:00
|
|
|
{
|
2016-09-15 18:12:09 +00:00
|
|
|
ASSERT(isDoubleDotPathSegment(c));
|
2016-10-29 00:20:38 +00:00
|
|
|
if (*c == '.')
|
|
|
|
advance(c);
|
|
|
|
else {
|
|
|
|
ASSERT(*c == '%');
|
|
|
|
advance(c);
|
|
|
|
ASSERT(*c == dotASCIICode[0]);
|
|
|
|
advance(c);
|
|
|
|
ASSERT(toASCIILower(*c) == dotASCIICode[1]);
|
|
|
|
advance(c);
|
|
|
|
}
|
2016-09-15 18:12:09 +00:00
|
|
|
consumeSingleDotPathSegment(c);
|
2016-09-01 20:33:31 +00:00
|
|
|
}
|
|
|
|
|
2017-02-24 16:45:32 +00:00
|
|
|
bool URLParser::shouldPopPath(unsigned newPathAfterLastSlash)
|
|
|
|
{
|
|
|
|
ASSERT(m_didSeeSyntaxViolation);
|
|
|
|
if (!m_urlIsFile)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
ASSERT(m_url.m_pathAfterLastSlash <= m_asciiBuffer.size());
|
|
|
|
CodePointIterator<LChar> componentToPop(&m_asciiBuffer[newPathAfterLastSlash], &m_asciiBuffer[0] + m_url.m_pathAfterLastSlash);
|
2018-07-13 00:28:36 +00:00
|
|
|
if (newPathAfterLastSlash == m_url.m_hostEnd + m_url.m_portLength + 1 && isWindowsDriveLetter(componentToPop))
|
2017-02-24 16:45:32 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-09-01 20:33:31 +00:00
|
|
|
void URLParser::popPath()
|
|
|
|
{
|
2016-09-28 01:23:50 +00:00
|
|
|
ASSERT(m_didSeeSyntaxViolation);
|
2018-07-13 00:28:36 +00:00
|
|
|
if (m_url.m_pathAfterLastSlash > m_url.m_hostEnd + m_url.m_portLength + 1) {
|
2017-02-24 16:45:32 +00:00
|
|
|
auto newPathAfterLastSlash = m_url.m_pathAfterLastSlash - 1;
|
|
|
|
if (m_asciiBuffer[newPathAfterLastSlash] == '/')
|
|
|
|
newPathAfterLastSlash--;
|
2018-07-13 00:28:36 +00:00
|
|
|
while (newPathAfterLastSlash > m_url.m_hostEnd + m_url.m_portLength && m_asciiBuffer[newPathAfterLastSlash] != '/')
|
2017-02-24 16:45:32 +00:00
|
|
|
newPathAfterLastSlash--;
|
|
|
|
newPathAfterLastSlash++;
|
|
|
|
if (shouldPopPath(newPathAfterLastSlash))
|
|
|
|
m_url.m_pathAfterLastSlash = newPathAfterLastSlash;
|
2016-09-01 20:33:31 +00:00
|
|
|
}
|
2016-09-16 20:35:16 +00:00
|
|
|
m_asciiBuffer.resize(m_url.m_pathAfterLastSlash);
|
2016-09-01 20:33:31 +00:00
|
|
|
}
|
|
|
|
|
2016-09-23 23:40:46 +00:00
|
|
|
template<typename CharacterType>
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
void URLParser::syntaxViolation(const CodePointIterator<CharacterType>& iterator)
|
2016-09-23 23:40:46 +00:00
|
|
|
{
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (m_didSeeSyntaxViolation)
|
|
|
|
return;
|
|
|
|
m_didSeeSyntaxViolation = true;
|
|
|
|
|
|
|
|
ASSERT(m_asciiBuffer.isEmpty());
|
|
|
|
size_t codeUnitsToCopy = iterator.codeUnitsSince(reinterpret_cast<const CharacterType*>(m_inputBegin));
|
|
|
|
RELEASE_ASSERT(codeUnitsToCopy <= m_inputString.length());
|
|
|
|
m_asciiBuffer.reserveCapacity(m_inputString.length());
|
|
|
|
for (size_t i = 0; i < codeUnitsToCopy; ++i) {
|
|
|
|
ASSERT(isASCII(m_inputString[i]));
|
|
|
|
m_asciiBuffer.uncheckedAppend(m_inputString[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-23 20:58:03 +00:00
|
|
|
void URLParser::failure()
|
2016-09-09 00:43:50 +00:00
|
|
|
{
|
2016-09-23 20:58:03 +00:00
|
|
|
m_url.invalidate();
|
|
|
|
m_url.m_string = m_inputString;
|
2016-09-09 00:43:50 +00:00
|
|
|
}
|
|
|
|
|
2016-09-29 18:18:04 +00:00
|
|
|
template<typename CharacterType>
|
|
|
|
bool URLParser::checkLocalhostCodePoint(CodePointIterator<CharacterType>& iterator, UChar32 codePoint)
|
|
|
|
{
|
|
|
|
if (iterator.atEnd() || toASCIILower(*iterator) != codePoint)
|
|
|
|
return false;
|
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(iterator);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename CharacterType>
|
|
|
|
bool URLParser::isAtLocalhost(CodePointIterator<CharacterType> iterator)
|
|
|
|
{
|
|
|
|
if (!checkLocalhostCodePoint(iterator, 'l'))
|
|
|
|
return false;
|
|
|
|
if (!checkLocalhostCodePoint(iterator, 'o'))
|
|
|
|
return false;
|
|
|
|
if (!checkLocalhostCodePoint(iterator, 'c'))
|
|
|
|
return false;
|
|
|
|
if (!checkLocalhostCodePoint(iterator, 'a'))
|
|
|
|
return false;
|
|
|
|
if (!checkLocalhostCodePoint(iterator, 'l'))
|
|
|
|
return false;
|
|
|
|
if (!checkLocalhostCodePoint(iterator, 'h'))
|
|
|
|
return false;
|
|
|
|
if (!checkLocalhostCodePoint(iterator, 'o'))
|
|
|
|
return false;
|
|
|
|
if (!checkLocalhostCodePoint(iterator, 's'))
|
|
|
|
return false;
|
|
|
|
if (!checkLocalhostCodePoint(iterator, 't'))
|
|
|
|
return false;
|
|
|
|
return iterator.atEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool URLParser::isLocalhost(StringView view)
|
|
|
|
{
|
|
|
|
if (view.is8Bit())
|
|
|
|
return isAtLocalhost(CodePointIterator<LChar>(view.characters8(), view.characters8() + view.length()));
|
|
|
|
return isAtLocalhost(CodePointIterator<UChar>(view.characters16(), view.characters16() + view.length()));
|
|
|
|
}
|
|
|
|
|
2016-09-28 01:23:50 +00:00
|
|
|
ALWAYS_INLINE StringView URLParser::parsedDataView(size_t start, size_t length)
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
{
|
|
|
|
if (UNLIKELY(m_didSeeSyntaxViolation)) {
|
|
|
|
ASSERT(start + length <= m_asciiBuffer.size());
|
|
|
|
return StringView(m_asciiBuffer.data() + start, length);
|
|
|
|
}
|
|
|
|
ASSERT(start + length <= m_inputString.length());
|
|
|
|
return StringView(m_inputString).substring(start, length);
|
|
|
|
}
|
|
|
|
|
2016-11-16 22:53:48 +00:00
|
|
|
ALWAYS_INLINE UChar URLParser::parsedDataView(size_t position)
|
|
|
|
{
|
|
|
|
if (UNLIKELY(m_didSeeSyntaxViolation))
|
|
|
|
return m_asciiBuffer[position];
|
|
|
|
return m_inputString[position];
|
|
|
|
}
|
|
|
|
|
2016-09-23 23:40:46 +00:00
|
|
|
template<typename CharacterType>
|
2016-09-28 01:23:50 +00:00
|
|
|
ALWAYS_INLINE size_t URLParser::currentPosition(const CodePointIterator<CharacterType>& iterator)
|
2016-09-23 23:40:46 +00:00
|
|
|
{
|
2016-10-11 18:28:50 +00:00
|
|
|
if (UNLIKELY(m_didSeeSyntaxViolation))
|
2016-09-23 23:40:46 +00:00
|
|
|
return m_asciiBuffer.size();
|
|
|
|
|
|
|
|
return iterator.codeUnitsSince(reinterpret_cast<const CharacterType*>(m_inputBegin));
|
|
|
|
}
|
|
|
|
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
URLParser::URLParser(const String& input, const URL& base, const URLTextEncoding* nonUTF8QueryEncoding)
|
2016-09-23 20:58:03 +00:00
|
|
|
: m_inputString(input)
|
2016-08-11 19:09:39 +00:00
|
|
|
{
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (input.isNull()) {
|
2016-10-03 17:28:04 +00:00
|
|
|
if (base.isValid() && !base.m_cannotBeABaseURL) {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
m_url = base;
|
2016-10-03 17:28:04 +00:00
|
|
|
m_url.removeFragmentIdentifier();
|
|
|
|
}
|
2016-09-23 20:58:03 +00:00
|
|
|
return;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
}
|
2016-09-23 22:32:28 +00:00
|
|
|
|
2016-09-23 23:40:46 +00:00
|
|
|
if (input.is8Bit()) {
|
|
|
|
m_inputBegin = input.characters8();
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
parse(input.characters8(), input.length(), base, nonUTF8QueryEncoding);
|
2016-09-23 23:40:46 +00:00
|
|
|
} else {
|
|
|
|
m_inputBegin = input.characters16();
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
parse(input.characters16(), input.length(), base, nonUTF8QueryEncoding);
|
2016-09-23 23:40:46 +00:00
|
|
|
}
|
2016-09-29 18:18:04 +00:00
|
|
|
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
ASSERT(!m_url.m_isValid
|
|
|
|
|| m_didSeeSyntaxViolation == (m_url.string() != input)
|
2020-10-02 20:59:11 +00:00
|
|
|
|| (input.isAllSpecialCharacters<isC0ControlOrSpace>() && m_url.m_string == base.m_string.left(base.m_queryEnd))
|
|
|
|
|| (base.isValid() && base.protocolIs("file")));
|
2016-09-29 18:18:04 +00:00
|
|
|
ASSERT(internalValuesConsistent(m_url));
|
PerformanceTests:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* JetStream2/wasm/HashSet.cpp:
* StitchMarker/wtf/Assertions.h:
* StitchMarker/wtf/DateMath.cpp:
(WTF::initializeDates):
* StitchMarker/wtf/HashTable.h:
* StitchMarker/wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
* StitchMarker/wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* StitchMarker/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* StitchMarker/wtf/ValueCheck.h:
* StitchMarker/wtf/Vector.h:
(WTF::minCapacity>::checkConsistency):
* StitchMarker/wtf/text/AtomicStringImpl.cpp:
* StitchMarker/wtf/text/AtomicStringImpl.h:
* StitchMarker/wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* StitchMarker/wtf/text/StringImpl.h:
* StitchMarker/wtf/text/SymbolImpl.h:
* StitchMarker/wtf/text/UniquedStringImpl.h:
Source/JavaScriptCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* API/tests/testapi.c:
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithLoad):
(JSC::ARM64Assembler::replaceWithAddressComputation):
* assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::LocalWriter::LocalWriter):
* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::Stack):
* assembler/ProbeStack.h:
* b3/B3FoldPathConstants.cpp:
* b3/B3LowerToAir.cpp:
* b3/B3MemoryValue.cpp:
(JSC::B3::MemoryValue::MemoryValue):
* b3/B3Opcode.cpp:
* b3/B3Type.h:
* b3/B3TypeMap.h:
* b3/B3Width.h:
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration):
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.h:
* b3/air/AirAllocateRegistersByGraphColoring.cpp:
* b3/air/AirArg.cpp:
* b3/air/AirArg.h:
* b3/air/AirCode.h:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/AccessCase.cpp:
* bytecode/AccessCase.h:
* bytecode/CallVariant.cpp:
(JSC::variantListWithVariant):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex):
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::dump const):
* bytecode/StructureStubInfo.cpp:
* bytecode/StructureStubInfo.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionCallResolveNode::emitBytecode):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
* debugger/Debugger.cpp:
(JSC::Debugger::removeBreakpoint):
* debugger/DebuggerEvalEnabler.h:
(JSC::DebuggerEvalEnabler::DebuggerEvalEnabler):
(JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions):
* dfg/DFGAbstractValue.cpp:
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::merge):
(JSC::DFG::AbstractValue::checkConsistency const):
(JSC::DFG::AbstractValue::assertIsRegistered const):
* dfg/DFGArithMode.h:
(JSC::DFG::doesOverflow):
* dfg/DFGBasicBlock.cpp:
(JSC::DFG::BasicBlock::BasicBlock):
* dfg/DFGBasicBlock.h:
(JSC::DFG::BasicBlock::didLink):
* dfg/DFGCFAPhase.cpp:
(JSC::DFG::CFAPhase::performBlockCFA):
* dfg/DFGCommon.h:
(JSC::DFG::validationEnabled):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGEdge.h:
(JSC::DFG::Edge::makeWord):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::assertClear):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::SlowPathGenerator::generate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
(JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse):
(JSC::DFG::SpeculativeJIT::emitAllocateButterfly):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
* dfg/DFGStructureAbstractValue.cpp:
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::assertIsRegistered const):
* dfg/DFGVarargsForwardingPhase.cpp:
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::callPreflight):
(JSC::FTL::DFG::LowerDFGToB3::callCheck):
(JSC::FTL::DFG::LowerDFGToB3::crash):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::assertNoUnswept):
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::validatePrevious):
* heap/HandleSet.cpp:
* heap/HandleSet.h:
* heap/Heap.cpp:
(JSC::Heap::updateAllocationLimits):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::assertValidCell const):
(JSC::MarkedBlock::assertMarksNotStale):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::beginMarking):
(JSC::MarkedSpace::endMarking):
(JSC::MarkedSpace::assertNoUnswept):
* heap/PreciseAllocation.cpp:
* heap/PreciseAllocation.h:
(JSC::PreciseAllocation::assertValidCell const):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
* heap/SlotVisitor.h:
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
(CppProtocolTypesImplementationGenerator):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* interpreter/FrameTracers.h:
(JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
* interpreter/Interpreter.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::prepareCallOperation):
* jit/BinarySwitch.cpp:
(JSC::BinarySwitch::BinarySwitch):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupStubArgs):
* jit/CallFrameShuffler.cpp:
(JSC::CallFrameShuffler::emitDeltaCheck):
(JSC::CallFrameShuffler::prepareAny):
* jit/JIT.cpp:
(JSC::JIT::assertStackPointerOffset):
(JSC::JIT::compileWithoutLinking):
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_loop_hint):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jit/ThunkGenerators.cpp:
(JSC::emitPointerValidation):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LLIntOfflineAsmConfig.h:
* parser/Lexer.cpp:
* parser/Lexer.h:
(JSC::isSafeBuiltinIdentifier):
(JSC::Lexer<T>::lexExpectIdentifier):
* runtime/ArgList.h:
(JSC::MarkedArgumentBuffer::setNeedsOverflowCheck):
(JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck):
* runtime/Butterfly.h:
(JSC::ContiguousData::ContiguousData):
(JSC::ContiguousData::Data::Data):
* runtime/HashMapImpl.h:
(JSC::HashMapImpl::checkConsistency const):
(JSC::HashMapImpl::assertBufferIsEmpty const):
* runtime/JSCellInlines.h:
(JSC::JSCell::methodTable const):
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
(JSC::JSFunction::assertTypeInfoFlagInvariants):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren):
(JSC::JSFinalObject::visitChildren):
* runtime/JSObjectInlines.h:
(JSC::JSObject::validatePutOwnDataProperty):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::assertVariableIsInThisObject):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lex):
* runtime/LiteralParser.h:
* runtime/Operations.h:
(JSC::scribbleFreeCells):
* runtime/OptionsList.h:
* runtime/VM.cpp:
(JSC::VM::computeCanUseJIT):
* runtime/VM.h:
(JSC::VM::canUseJIT):
* runtime/VarOffset.h:
(JSC::VarOffset::checkSanity const):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::checkConsistency const):
(JSC::WeakMapImpl::assertBufferIsEmpty const):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::validateInst):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::validationFail const):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::checkConsistency):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast):
* wasm/WasmSectionParser.h:
* wasm/WasmSections.h:
* wasm/WasmSignatureInlines.h:
(JSC::Wasm::SignatureInformation::get):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::enqueue):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::previousInstanceOffset const):
Source/WebCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTask::performTask):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::terminationRequested const):
* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h:
(WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation):
* Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp:
(WebCore::WHLSL::findHighZombies):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::matches):
* Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:
(WebCore::WHLSL::checkLiteralTypes):
* Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp:
(WebCore::WHLSL::FindAllTypes::appendNamedType):
* bindings/js/JSCallbackData.h:
* bindings/js/JSLazyEventListener.cpp:
* bindings/js/JSLazyEventListener.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::primitiveType const):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValue.cpp:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSStyleSheet.cpp:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::suspendIfNeeded):
(WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const):
* dom/ActiveDOMObject.h:
* dom/ContainerNode.cpp:
* dom/ContainerNodeAlgorithms.cpp:
* dom/ContainerNodeAlgorithms.h:
* dom/CustomElementReactionQueue.cpp:
* dom/CustomElementReactionQueue.h:
(WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope):
(WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope):
* dom/Document.cpp:
(WebCore::Document::hitTest):
* dom/Document.h:
(WebCore::Document::decrementReferencingNodeCount):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::getURLAttribute const):
(WebCore::Element::getNonEmptyURLAttribute const):
* dom/Element.h:
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::dropAssertions):
(WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack):
(WebCore::ElementAndTextDescendantIterator::traverseNextSibling):
(WebCore::ElementAndTextDescendantIterator::traversePreviousSibling):
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::ElementDescendantIterator):
(WebCore::ElementDescendantIterator::dropAssertions):
(WebCore::ElementDescendantIterator::operator++):
(WebCore::ElementDescendantIterator::operator--):
(WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator):
(WebCore::ElementDescendantConstIterator::dropAssertions):
(WebCore::ElementDescendantConstIterator::operator++):
* dom/ElementIterator.h:
(WebCore::ElementIterator<ElementType>::ElementIterator):
(WebCore::ElementIterator<ElementType>::traverseNext):
(WebCore::ElementIterator<ElementType>::traversePrevious):
(WebCore::ElementIterator<ElementType>::traverseNextSibling):
(WebCore::ElementIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementIterator<ElementType>::dropAssertions):
(WebCore::ElementIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::ElementConstIterator):
(WebCore::ElementConstIterator<ElementType>::traverseNext):
(WebCore::ElementConstIterator<ElementType>::traversePrevious):
(WebCore::ElementConstIterator<ElementType>::traverseNextSibling):
(WebCore::ElementConstIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementConstIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::dropAssertions):
* dom/EventContext.cpp:
* dom/EventContext.h:
* dom/EventListener.h:
* dom/EventPath.cpp:
* dom/EventSender.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::setAttributeEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::deref const):
* dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute const):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::resolveSlotsAfterSlotMutation):
(WebCore::SlotAssignment::findFirstSlotElement):
* dom/SlotAssignment.h:
* dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::add):
(WebCore::TreeScopeOrderedMap::get const):
* dom/TreeScopeOrderedMap.h:
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::removeAllItemsForPage):
* history/BackForwardCache.h:
* html/CanvasBase.cpp:
(WebCore::CanvasBase::notifyObserversCanvasDestroyed):
* html/CanvasBase.h:
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
* html/HTMLSelectElement.cpp:
(WebCore:: const):
* html/HTMLTableRowsCollection.cpp:
(WebCore::assertRowIsInTable):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForPosition const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::endAttribute):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::constructTree):
* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::~HTMLTreeBuilder):
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::geometryForBox const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setContentBoxHeight):
(WebCore::Display::Box::setContentBoxWidth):
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):
* layout/displaytree/DisplayInlineRect.h:
(WebCore::Display::InlineRect::InlineRect):
(WebCore::Display::InlineRect::setTopLeft):
(WebCore::Display::InlineRect::setTop):
(WebCore::Display::InlineRect::setBottom):
(WebCore::Display::InlineRect::setLeft):
(WebCore::Display::InlineRect::setWidth):
(WebCore::Display::InlineRect::setHeight):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::setBaselineOffsetIfGreater):
(WebCore::Display::LineBox::resetBaseline):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::Baseline::setAscent):
(WebCore::Display::LineBox::Baseline::setDescent):
(WebCore::Display::LineBox::Baseline::reset):
* layout/displaytree/DisplayRect.h:
(WebCore::Display::Rect::Rect):
(WebCore::Display::Rect::setTopLeft):
(WebCore::Display::Rect::setTop):
(WebCore::Display::Rect::setLeft):
(WebCore::Display::Rect::setWidth):
(WebCore::Display::Rect::setHeight):
(WebCore::Display::Rect::setSize):
(WebCore::Display::Rect::clone const):
* layout/floats/FloatingContext.cpp:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::Column::setWidthConstraints):
(WebCore::Layout::TableGrid::Column::setLogicalWidth):
(WebCore::Layout::TableGrid::Column::setLogicalLeft):
* layout/tableformatting/TableGrid.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/DocumentLoader.h:
* loader/ImageLoader.cpp:
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/FrameViewLayoutContext.cpp:
* page/FrameViewLayoutContext.h:
* page/Page.cpp:
* page/Page.h:
* page/ViewportConfiguration.cpp:
* page/ViewportConfiguration.h:
* page/mac/EventHandlerMac.mm:
(WebCore::CurrentEventScope::CurrentEventScope):
* platform/DateComponents.cpp:
(WebCore::DateComponents::toStringForTime const):
* platform/ScrollableArea.cpp:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::combineIntoOneSegment const):
* platform/SharedBuffer.h:
* platform/Supplementable.h:
* platform/Timer.cpp:
(WebCore::TimerBase::checkHeapIndex const):
(WebCore::TimerBase::updateHeapIfNeeded):
* platform/graphics/BitmapImage.cpp:
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::ScratchBuffer):
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ScratchBuffer::scheduleScratchBufferPurge):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::setWindow):
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp:
(gstAllocatorFastMallocFree):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createTile):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::fill):
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::appendGeometry):
(WebCore::Path::Path):
(WebCore::Path::operator=):
(WebCore::Path::strokeContains const):
(WebCore::Path::transform):
* platform/graphics/win/PlatformContextDirect2D.cpp:
(WebCore::PlatformContextDirect2D::setTags):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
* platform/network/HTTPParsers.cpp:
(WebCore::isCrossOriginSafeHeader):
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::SQLiteStatement):
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::finalize):
* platform/sql/SQLiteStatement.h:
* platform/win/COMPtr.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::removeInlineBox const):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
(WebCore::FloatingObjects::addPlacedObject):
(WebCore::FloatingObjects::removePlacedObject):
* rendering/FloatingObjects.h:
* rendering/GridTrackSizingAlgorithm.cpp:
* rendering/GridTrackSizingAlgorithm.h:
* rendering/LayoutDisallowedScope.cpp:
* rendering/LayoutDisallowedScope.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderElement.cpp:
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::baselinePosition const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::ClipRectsCache::ClipRectsCache):
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::traverseVisibleNonCompositedDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const):
(WebCore::RenderLayerCompositor::recursiveRepaintLayer):
(WebCore::RenderLayerCompositor::layerHas3DContent const):
* rendering/RenderLayoutState.cpp:
(WebCore::RenderLayoutState::RenderLayoutState):
(WebCore::RenderLayoutState::computeOffsets):
(WebCore::RenderLayoutState::addLayoutDelta):
* rendering/RenderLayoutState.h:
(WebCore::RenderLayoutState::RenderLayoutState):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::~RenderObject):
(WebCore::RenderObject::clearNeedsLayout):
* rendering/RenderObject.h:
* rendering/RenderQuote.cpp:
(WebCore::quotesForLanguage):
* rendering/RenderTableCell.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::computeOverflowFromCells):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::checkConsistency const):
* rendering/RenderTextLineBoxes.h:
* rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::~RenderStyle):
* rendering/style/RenderStyle.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::detach):
* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):
* rendering/updating/RenderTreePosition.h:
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::firstGlyph const):
(WebCore::SVGToOTFFontConverter::appendKERNTable):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::SVGTransformDistance):
(WebCore::SVGTransformDistance::scaledDistance const):
(WebCore::SVGTransformDistance::addSVGTransforms):
(WebCore::SVGTransformDistance::addToSVGTransform const):
(WebCore::SVGTransformDistance::distance const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
* testing/InternalSettings.cpp:
* workers/service/ServiceWorkerJob.h:
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* xml/XPathStep.cpp:
Source/WebKit:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::invalidateAndCancel):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::setCapacity):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* Platform/IPC/Connection.cpp:
(IPC::Connection::waitForMessage):
* Platform/IPC/MessageReceiver.h:
(IPC::MessageReceiver::willBeAddedToMessageReceiverMap):
(IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::readFromMachPort):
* Platform/mac/MachUtilities.cpp:
(setMachExceptionPort):
* Shared/API/APIClient.h:
(API::Client::Client):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
* Shared/Cocoa/ArgumentCodersCocoa.h:
* Shared/SharedStringHashTableReadOnly.cpp:
* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/GenericCallback.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Transaction::Token::Token):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy):
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runModal):
* WebProcess/WebProcess.cpp:
(WebKit::checkDocumentsCaptureStateConsistency):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateProcessName):
Source/WebKitLegacy:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::StorageAreaImpl):
(WebKit::StorageAreaImpl::close):
* Storage/StorageAreaImpl.h:
Source/WebKitLegacy/mac:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* History/WebHistory.mm:
(-[WebHistoryPrivate removeItemForURLString:]):
* WebView/WebFrame.mm:
Source/WebKitLegacy/win:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::swapChain):
(WKQCA::CAD3DRenderer::initialize):
* WebKitQuartzCoreAdditions/CAD3DRenderer.h:
* WebView.cpp:
(WebView::Release):
* WebView.h:
Source/WTF:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
This patch did the following changes:
1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away
with the need for the double negative !ASSERT_DISABLED test that is commonly
used all over the code, thereby improving code readability.
In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED,
ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and
RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents
as well. We'll do that in another patch. For now, they are left as is to
minimize the size of this patch.
See https://bugs.webkit.org/show_bug.cgi?id=205780.
2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be
guarded by "#if ASSERT_ENABLED" instead.
3. In cases where the change is minimal, we move some code around so that we can
test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED".
* wtf/Assertions.h:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/BitVector.h:
* wtf/BlockObjCExceptions.mm:
(ReportBlockedObjCException):
* wtf/BloomFilter.h:
* wtf/CallbackAggregator.h:
(WTF::CallbackAggregator::CallbackAggregator):
* wtf/CheckedArithmetic.h:
(WTF::observesOverflow<AssertNoOverflow>):
* wtf/CheckedBoolean.h:
(CheckedBoolean::CheckedBoolean):
(CheckedBoolean::operator bool):
* wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* wtf/DateMath.cpp:
(WTF::initializeDates):
* wtf/Gigacage.cpp:
(Gigacage::tryAllocateZeroedVirtualPages):
* wtf/HashTable.h:
(WTF::KeyTraits>::checkKey):
(WTF::KeyTraits>::checkTableConsistencyExceptSize const):
* wtf/LoggerHelper.h:
* wtf/NaturalLoops.h:
(WTF::NaturalLoops::headerOf const):
* wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
* wtf/Platform.h:
* wtf/PtrTag.h:
* wtf/RefCounted.h:
(WTF::RefCountedBase::disableThreadingChecks):
(WTF::RefCountedBase::enableThreadingChecksGlobally):
(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
* wtf/SingleRootGraph.h:
(WTF::SingleRootGraph::assertIsConsistent const):
* wtf/SizeLimits.cpp:
* wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::domainToASCII):
* wtf/ValueCheck.h:
* wtf/Vector.h:
(WTF::Malloc>::checkConsistency):
* wtf/WeakHashSet.h:
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::WeakPtrImpl):
(WTF::WeakPtrFactory::WeakPtrFactory):
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringImpl.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString const):
* wtf/text/StringBuilder.h:
* wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* wtf/text/StringHasher.h:
(WTF::StringHasher::addCharacters):
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
Tools:
Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory
https://bugs.webkit.org/show_bug.cgi?id=205754
Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06
Reviewed by Youenn Fablet.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::websiteDataStore):
(WTR::TestController::platformAdjustContext):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
Canonical link: https://commits.webkit.org/218957@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
|
|
|
#if ASSERT_ENABLED
|
2016-09-29 18:18:04 +00:00
|
|
|
if (!m_didSeeSyntaxViolation) {
|
|
|
|
// Force a syntax violation at the beginning to make sure we get the same result.
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
URLParser parser(makeString(" ", input), base, nonUTF8QueryEncoding);
|
2016-09-29 18:18:04 +00:00
|
|
|
URL parsed = parser.result();
|
|
|
|
if (parsed.isValid())
|
|
|
|
ASSERT(allValuesEqual(parser.result(), m_url));
|
|
|
|
}
|
PerformanceTests:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* JetStream2/wasm/HashSet.cpp:
* StitchMarker/wtf/Assertions.h:
* StitchMarker/wtf/DateMath.cpp:
(WTF::initializeDates):
* StitchMarker/wtf/HashTable.h:
* StitchMarker/wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
* StitchMarker/wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* StitchMarker/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* StitchMarker/wtf/ValueCheck.h:
* StitchMarker/wtf/Vector.h:
(WTF::minCapacity>::checkConsistency):
* StitchMarker/wtf/text/AtomicStringImpl.cpp:
* StitchMarker/wtf/text/AtomicStringImpl.h:
* StitchMarker/wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* StitchMarker/wtf/text/StringImpl.h:
* StitchMarker/wtf/text/SymbolImpl.h:
* StitchMarker/wtf/text/UniquedStringImpl.h:
Source/JavaScriptCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* API/tests/testapi.c:
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithLoad):
(JSC::ARM64Assembler::replaceWithAddressComputation):
* assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::LocalWriter::LocalWriter):
* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::Stack):
* assembler/ProbeStack.h:
* b3/B3FoldPathConstants.cpp:
* b3/B3LowerToAir.cpp:
* b3/B3MemoryValue.cpp:
(JSC::B3::MemoryValue::MemoryValue):
* b3/B3Opcode.cpp:
* b3/B3Type.h:
* b3/B3TypeMap.h:
* b3/B3Width.h:
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration):
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.h:
* b3/air/AirAllocateRegistersByGraphColoring.cpp:
* b3/air/AirArg.cpp:
* b3/air/AirArg.h:
* b3/air/AirCode.h:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/AccessCase.cpp:
* bytecode/AccessCase.h:
* bytecode/CallVariant.cpp:
(JSC::variantListWithVariant):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex):
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::dump const):
* bytecode/StructureStubInfo.cpp:
* bytecode/StructureStubInfo.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionCallResolveNode::emitBytecode):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
* debugger/Debugger.cpp:
(JSC::Debugger::removeBreakpoint):
* debugger/DebuggerEvalEnabler.h:
(JSC::DebuggerEvalEnabler::DebuggerEvalEnabler):
(JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions):
* dfg/DFGAbstractValue.cpp:
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::merge):
(JSC::DFG::AbstractValue::checkConsistency const):
(JSC::DFG::AbstractValue::assertIsRegistered const):
* dfg/DFGArithMode.h:
(JSC::DFG::doesOverflow):
* dfg/DFGBasicBlock.cpp:
(JSC::DFG::BasicBlock::BasicBlock):
* dfg/DFGBasicBlock.h:
(JSC::DFG::BasicBlock::didLink):
* dfg/DFGCFAPhase.cpp:
(JSC::DFG::CFAPhase::performBlockCFA):
* dfg/DFGCommon.h:
(JSC::DFG::validationEnabled):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGEdge.h:
(JSC::DFG::Edge::makeWord):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::assertClear):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::SlowPathGenerator::generate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
(JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse):
(JSC::DFG::SpeculativeJIT::emitAllocateButterfly):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
* dfg/DFGStructureAbstractValue.cpp:
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::assertIsRegistered const):
* dfg/DFGVarargsForwardingPhase.cpp:
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::callPreflight):
(JSC::FTL::DFG::LowerDFGToB3::callCheck):
(JSC::FTL::DFG::LowerDFGToB3::crash):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::assertNoUnswept):
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::validatePrevious):
* heap/HandleSet.cpp:
* heap/HandleSet.h:
* heap/Heap.cpp:
(JSC::Heap::updateAllocationLimits):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::assertValidCell const):
(JSC::MarkedBlock::assertMarksNotStale):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::beginMarking):
(JSC::MarkedSpace::endMarking):
(JSC::MarkedSpace::assertNoUnswept):
* heap/PreciseAllocation.cpp:
* heap/PreciseAllocation.h:
(JSC::PreciseAllocation::assertValidCell const):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
* heap/SlotVisitor.h:
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
(CppProtocolTypesImplementationGenerator):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* interpreter/FrameTracers.h:
(JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
* interpreter/Interpreter.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::prepareCallOperation):
* jit/BinarySwitch.cpp:
(JSC::BinarySwitch::BinarySwitch):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupStubArgs):
* jit/CallFrameShuffler.cpp:
(JSC::CallFrameShuffler::emitDeltaCheck):
(JSC::CallFrameShuffler::prepareAny):
* jit/JIT.cpp:
(JSC::JIT::assertStackPointerOffset):
(JSC::JIT::compileWithoutLinking):
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_loop_hint):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jit/ThunkGenerators.cpp:
(JSC::emitPointerValidation):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LLIntOfflineAsmConfig.h:
* parser/Lexer.cpp:
* parser/Lexer.h:
(JSC::isSafeBuiltinIdentifier):
(JSC::Lexer<T>::lexExpectIdentifier):
* runtime/ArgList.h:
(JSC::MarkedArgumentBuffer::setNeedsOverflowCheck):
(JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck):
* runtime/Butterfly.h:
(JSC::ContiguousData::ContiguousData):
(JSC::ContiguousData::Data::Data):
* runtime/HashMapImpl.h:
(JSC::HashMapImpl::checkConsistency const):
(JSC::HashMapImpl::assertBufferIsEmpty const):
* runtime/JSCellInlines.h:
(JSC::JSCell::methodTable const):
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
(JSC::JSFunction::assertTypeInfoFlagInvariants):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren):
(JSC::JSFinalObject::visitChildren):
* runtime/JSObjectInlines.h:
(JSC::JSObject::validatePutOwnDataProperty):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::assertVariableIsInThisObject):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lex):
* runtime/LiteralParser.h:
* runtime/Operations.h:
(JSC::scribbleFreeCells):
* runtime/OptionsList.h:
* runtime/VM.cpp:
(JSC::VM::computeCanUseJIT):
* runtime/VM.h:
(JSC::VM::canUseJIT):
* runtime/VarOffset.h:
(JSC::VarOffset::checkSanity const):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::checkConsistency const):
(JSC::WeakMapImpl::assertBufferIsEmpty const):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::validateInst):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::validationFail const):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::checkConsistency):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast):
* wasm/WasmSectionParser.h:
* wasm/WasmSections.h:
* wasm/WasmSignatureInlines.h:
(JSC::Wasm::SignatureInformation::get):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::enqueue):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::previousInstanceOffset const):
Source/WebCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTask::performTask):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::terminationRequested const):
* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h:
(WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation):
* Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp:
(WebCore::WHLSL::findHighZombies):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::matches):
* Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:
(WebCore::WHLSL::checkLiteralTypes):
* Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp:
(WebCore::WHLSL::FindAllTypes::appendNamedType):
* bindings/js/JSCallbackData.h:
* bindings/js/JSLazyEventListener.cpp:
* bindings/js/JSLazyEventListener.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::primitiveType const):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValue.cpp:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSStyleSheet.cpp:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::suspendIfNeeded):
(WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const):
* dom/ActiveDOMObject.h:
* dom/ContainerNode.cpp:
* dom/ContainerNodeAlgorithms.cpp:
* dom/ContainerNodeAlgorithms.h:
* dom/CustomElementReactionQueue.cpp:
* dom/CustomElementReactionQueue.h:
(WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope):
(WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope):
* dom/Document.cpp:
(WebCore::Document::hitTest):
* dom/Document.h:
(WebCore::Document::decrementReferencingNodeCount):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::getURLAttribute const):
(WebCore::Element::getNonEmptyURLAttribute const):
* dom/Element.h:
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::dropAssertions):
(WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack):
(WebCore::ElementAndTextDescendantIterator::traverseNextSibling):
(WebCore::ElementAndTextDescendantIterator::traversePreviousSibling):
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::ElementDescendantIterator):
(WebCore::ElementDescendantIterator::dropAssertions):
(WebCore::ElementDescendantIterator::operator++):
(WebCore::ElementDescendantIterator::operator--):
(WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator):
(WebCore::ElementDescendantConstIterator::dropAssertions):
(WebCore::ElementDescendantConstIterator::operator++):
* dom/ElementIterator.h:
(WebCore::ElementIterator<ElementType>::ElementIterator):
(WebCore::ElementIterator<ElementType>::traverseNext):
(WebCore::ElementIterator<ElementType>::traversePrevious):
(WebCore::ElementIterator<ElementType>::traverseNextSibling):
(WebCore::ElementIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementIterator<ElementType>::dropAssertions):
(WebCore::ElementIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::ElementConstIterator):
(WebCore::ElementConstIterator<ElementType>::traverseNext):
(WebCore::ElementConstIterator<ElementType>::traversePrevious):
(WebCore::ElementConstIterator<ElementType>::traverseNextSibling):
(WebCore::ElementConstIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementConstIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::dropAssertions):
* dom/EventContext.cpp:
* dom/EventContext.h:
* dom/EventListener.h:
* dom/EventPath.cpp:
* dom/EventSender.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::setAttributeEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::deref const):
* dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute const):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::resolveSlotsAfterSlotMutation):
(WebCore::SlotAssignment::findFirstSlotElement):
* dom/SlotAssignment.h:
* dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::add):
(WebCore::TreeScopeOrderedMap::get const):
* dom/TreeScopeOrderedMap.h:
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::removeAllItemsForPage):
* history/BackForwardCache.h:
* html/CanvasBase.cpp:
(WebCore::CanvasBase::notifyObserversCanvasDestroyed):
* html/CanvasBase.h:
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
* html/HTMLSelectElement.cpp:
(WebCore:: const):
* html/HTMLTableRowsCollection.cpp:
(WebCore::assertRowIsInTable):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForPosition const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::endAttribute):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::constructTree):
* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::~HTMLTreeBuilder):
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::geometryForBox const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setContentBoxHeight):
(WebCore::Display::Box::setContentBoxWidth):
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):
* layout/displaytree/DisplayInlineRect.h:
(WebCore::Display::InlineRect::InlineRect):
(WebCore::Display::InlineRect::setTopLeft):
(WebCore::Display::InlineRect::setTop):
(WebCore::Display::InlineRect::setBottom):
(WebCore::Display::InlineRect::setLeft):
(WebCore::Display::InlineRect::setWidth):
(WebCore::Display::InlineRect::setHeight):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::setBaselineOffsetIfGreater):
(WebCore::Display::LineBox::resetBaseline):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::Baseline::setAscent):
(WebCore::Display::LineBox::Baseline::setDescent):
(WebCore::Display::LineBox::Baseline::reset):
* layout/displaytree/DisplayRect.h:
(WebCore::Display::Rect::Rect):
(WebCore::Display::Rect::setTopLeft):
(WebCore::Display::Rect::setTop):
(WebCore::Display::Rect::setLeft):
(WebCore::Display::Rect::setWidth):
(WebCore::Display::Rect::setHeight):
(WebCore::Display::Rect::setSize):
(WebCore::Display::Rect::clone const):
* layout/floats/FloatingContext.cpp:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::Column::setWidthConstraints):
(WebCore::Layout::TableGrid::Column::setLogicalWidth):
(WebCore::Layout::TableGrid::Column::setLogicalLeft):
* layout/tableformatting/TableGrid.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/DocumentLoader.h:
* loader/ImageLoader.cpp:
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/FrameViewLayoutContext.cpp:
* page/FrameViewLayoutContext.h:
* page/Page.cpp:
* page/Page.h:
* page/ViewportConfiguration.cpp:
* page/ViewportConfiguration.h:
* page/mac/EventHandlerMac.mm:
(WebCore::CurrentEventScope::CurrentEventScope):
* platform/DateComponents.cpp:
(WebCore::DateComponents::toStringForTime const):
* platform/ScrollableArea.cpp:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::combineIntoOneSegment const):
* platform/SharedBuffer.h:
* platform/Supplementable.h:
* platform/Timer.cpp:
(WebCore::TimerBase::checkHeapIndex const):
(WebCore::TimerBase::updateHeapIfNeeded):
* platform/graphics/BitmapImage.cpp:
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::ScratchBuffer):
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ScratchBuffer::scheduleScratchBufferPurge):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::setWindow):
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp:
(gstAllocatorFastMallocFree):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createTile):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::fill):
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::appendGeometry):
(WebCore::Path::Path):
(WebCore::Path::operator=):
(WebCore::Path::strokeContains const):
(WebCore::Path::transform):
* platform/graphics/win/PlatformContextDirect2D.cpp:
(WebCore::PlatformContextDirect2D::setTags):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
* platform/network/HTTPParsers.cpp:
(WebCore::isCrossOriginSafeHeader):
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::SQLiteStatement):
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::finalize):
* platform/sql/SQLiteStatement.h:
* platform/win/COMPtr.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::removeInlineBox const):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
(WebCore::FloatingObjects::addPlacedObject):
(WebCore::FloatingObjects::removePlacedObject):
* rendering/FloatingObjects.h:
* rendering/GridTrackSizingAlgorithm.cpp:
* rendering/GridTrackSizingAlgorithm.h:
* rendering/LayoutDisallowedScope.cpp:
* rendering/LayoutDisallowedScope.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderElement.cpp:
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::baselinePosition const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::ClipRectsCache::ClipRectsCache):
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::traverseVisibleNonCompositedDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const):
(WebCore::RenderLayerCompositor::recursiveRepaintLayer):
(WebCore::RenderLayerCompositor::layerHas3DContent const):
* rendering/RenderLayoutState.cpp:
(WebCore::RenderLayoutState::RenderLayoutState):
(WebCore::RenderLayoutState::computeOffsets):
(WebCore::RenderLayoutState::addLayoutDelta):
* rendering/RenderLayoutState.h:
(WebCore::RenderLayoutState::RenderLayoutState):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::~RenderObject):
(WebCore::RenderObject::clearNeedsLayout):
* rendering/RenderObject.h:
* rendering/RenderQuote.cpp:
(WebCore::quotesForLanguage):
* rendering/RenderTableCell.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::computeOverflowFromCells):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::checkConsistency const):
* rendering/RenderTextLineBoxes.h:
* rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::~RenderStyle):
* rendering/style/RenderStyle.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::detach):
* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):
* rendering/updating/RenderTreePosition.h:
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::firstGlyph const):
(WebCore::SVGToOTFFontConverter::appendKERNTable):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::SVGTransformDistance):
(WebCore::SVGTransformDistance::scaledDistance const):
(WebCore::SVGTransformDistance::addSVGTransforms):
(WebCore::SVGTransformDistance::addToSVGTransform const):
(WebCore::SVGTransformDistance::distance const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
* testing/InternalSettings.cpp:
* workers/service/ServiceWorkerJob.h:
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* xml/XPathStep.cpp:
Source/WebKit:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::invalidateAndCancel):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::setCapacity):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* Platform/IPC/Connection.cpp:
(IPC::Connection::waitForMessage):
* Platform/IPC/MessageReceiver.h:
(IPC::MessageReceiver::willBeAddedToMessageReceiverMap):
(IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::readFromMachPort):
* Platform/mac/MachUtilities.cpp:
(setMachExceptionPort):
* Shared/API/APIClient.h:
(API::Client::Client):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
* Shared/Cocoa/ArgumentCodersCocoa.h:
* Shared/SharedStringHashTableReadOnly.cpp:
* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/GenericCallback.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Transaction::Token::Token):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy):
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runModal):
* WebProcess/WebProcess.cpp:
(WebKit::checkDocumentsCaptureStateConsistency):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateProcessName):
Source/WebKitLegacy:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::StorageAreaImpl):
(WebKit::StorageAreaImpl::close):
* Storage/StorageAreaImpl.h:
Source/WebKitLegacy/mac:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* History/WebHistory.mm:
(-[WebHistoryPrivate removeItemForURLString:]):
* WebView/WebFrame.mm:
Source/WebKitLegacy/win:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::swapChain):
(WKQCA::CAD3DRenderer::initialize):
* WebKitQuartzCoreAdditions/CAD3DRenderer.h:
* WebView.cpp:
(WebView::Release):
* WebView.h:
Source/WTF:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
This patch did the following changes:
1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away
with the need for the double negative !ASSERT_DISABLED test that is commonly
used all over the code, thereby improving code readability.
In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED,
ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and
RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents
as well. We'll do that in another patch. For now, they are left as is to
minimize the size of this patch.
See https://bugs.webkit.org/show_bug.cgi?id=205780.
2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be
guarded by "#if ASSERT_ENABLED" instead.
3. In cases where the change is minimal, we move some code around so that we can
test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED".
* wtf/Assertions.h:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/BitVector.h:
* wtf/BlockObjCExceptions.mm:
(ReportBlockedObjCException):
* wtf/BloomFilter.h:
* wtf/CallbackAggregator.h:
(WTF::CallbackAggregator::CallbackAggregator):
* wtf/CheckedArithmetic.h:
(WTF::observesOverflow<AssertNoOverflow>):
* wtf/CheckedBoolean.h:
(CheckedBoolean::CheckedBoolean):
(CheckedBoolean::operator bool):
* wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* wtf/DateMath.cpp:
(WTF::initializeDates):
* wtf/Gigacage.cpp:
(Gigacage::tryAllocateZeroedVirtualPages):
* wtf/HashTable.h:
(WTF::KeyTraits>::checkKey):
(WTF::KeyTraits>::checkTableConsistencyExceptSize const):
* wtf/LoggerHelper.h:
* wtf/NaturalLoops.h:
(WTF::NaturalLoops::headerOf const):
* wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
* wtf/Platform.h:
* wtf/PtrTag.h:
* wtf/RefCounted.h:
(WTF::RefCountedBase::disableThreadingChecks):
(WTF::RefCountedBase::enableThreadingChecksGlobally):
(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
* wtf/SingleRootGraph.h:
(WTF::SingleRootGraph::assertIsConsistent const):
* wtf/SizeLimits.cpp:
* wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::domainToASCII):
* wtf/ValueCheck.h:
* wtf/Vector.h:
(WTF::Malloc>::checkConsistency):
* wtf/WeakHashSet.h:
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::WeakPtrImpl):
(WTF::WeakPtrFactory::WeakPtrFactory):
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringImpl.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString const):
* wtf/text/StringBuilder.h:
* wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* wtf/text/StringHasher.h:
(WTF::StringHasher::addCharacters):
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
Tools:
Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory
https://bugs.webkit.org/show_bug.cgi?id=205754
Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06
Reviewed by Youenn Fablet.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::websiteDataStore):
(WTR::TestController::platformAdjustContext):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
Canonical link: https://commits.webkit.org/218957@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
|
|
|
#endif // ASSERT_ENABLED
|
Non-special URLs are not idempotent
https://bugs.webkit.org/show_bug.cgi?id=215762
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/url-constructor-expected.txt:
* web-platform-tests/url/url-setters-expected.txt:
Source/WTF:
https://github.com/whatwg/url/pull/505 added an interesting edge case to the URL serialization:
"If url’s host is null, url’s path’s size is greater than 1, and url’s path[0] is the empty string, then append U+002F (/) followed by U+002E (.) to output."
The problem was that URLs like "a:/a/..//a" would be parsed into "a://a" with a pathname of "//a" and an empty host. If "a://a" was then reparsed, it would again have an href of "a://a"
but its host would be "a" and it would have an empty path. There is consensus that URL parsing should be idempotent, so we need to do something different here.
According to https://github.com/whatwg/url/issues/415#issuecomment-419197290 this follows what Edge did (and then subsequently abandoned when they switched to Chromium)
to make URL parsing idempotent by adding "/." before the path in the edge case of a URL with a non-special scheme (not http, https, wss, etc.) and a null host and a non-empty path that
has an empty first segment. All the members of the URL remain unchanged except the full serialization (href). This is not important in practice, but important in theory.
Our URL parser tries very hard to use the exact same WTF::String object given as input if it can. However, this step is better implemented as a post-processing step that will almost never happen
because otherwise we would have to parse the entire path twice to find out if we need to add "./" or if the "./" that may have already been there needs to stay. This is illustrated with the test URL
"t:/.//p/../../../..//x" which does need the "./".
In the common case, this adds one well-predicted branch to URL parsing, so I expect performance to be unaffected. Since this is such a rare edge case of URLs, I expect no compatibility problems.
* wtf/URL.cpp:
(WTF::URL::pathStart const):
* wtf/URL.h:
(WTF::URL::pathStart const): Deleted.
* wtf/URLParser.cpp:
(WTF::URLParser::copyURLPartsUntil):
(WTF::URLParser::URLParser):
(WTF::URLParser::needsNonSpecialDotSlash const):
(WTF::URLParser::addNonSpecialDotSlash):
* wtf/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WTF/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/229956@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267837 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-01 17:05:41 +00:00
|
|
|
|
|
|
|
if (UNLIKELY(needsNonSpecialDotSlash()))
|
|
|
|
addNonSpecialDotSlash();
|
2016-09-19 23:03:02 +00:00
|
|
|
}
|
2016-09-20 21:50:30 +00:00
|
|
|
|
2016-09-23 19:57:57 +00:00
|
|
|
template<typename CharacterType>
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
void URLParser::parse(const CharacterType* input, const unsigned length, const URL& base, const URLTextEncoding* nonUTF8QueryEncoding)
|
2016-09-15 18:12:09 +00:00
|
|
|
{
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
URL_PARSER_LOG("Parsing URL <%s> base <%s>", String(input, length).utf8().data(), base.string().utf8().data());
|
2016-08-17 00:41:30 +00:00
|
|
|
m_url = { };
|
2016-09-21 18:33:30 +00:00
|
|
|
ASSERT(m_asciiBuffer.isEmpty());
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
|
2016-09-20 21:50:30 +00:00
|
|
|
Vector<UChar> queryBuffer;
|
2016-08-17 00:41:30 +00:00
|
|
|
|
2016-09-15 18:12:09 +00:00
|
|
|
unsigned endIndex = length;
|
2021-07-08 22:59:59 +00:00
|
|
|
if (UNLIKELY(nonUTF8QueryEncoding == URLTextEncodingSentinelAllowingC0AtEndOfHash))
|
|
|
|
nonUTF8QueryEncoding = nullptr;
|
|
|
|
else {
|
|
|
|
while (UNLIKELY(endIndex && isC0ControlOrSpace(input[endIndex - 1]))) {
|
|
|
|
syntaxViolation(CodePointIterator<CharacterType>(input, input));
|
|
|
|
endIndex--;
|
|
|
|
}
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
}
|
2016-09-15 18:12:09 +00:00
|
|
|
CodePointIterator<CharacterType> c(input, input + endIndex);
|
|
|
|
CodePointIterator<CharacterType> authorityOrHostBegin;
|
2016-09-30 18:46:28 +00:00
|
|
|
CodePointIterator<CharacterType> queryBegin;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
while (UNLIKELY(!c.atEnd() && isC0ControlOrSpace(*c))) {
|
|
|
|
syntaxViolation(c);
|
2016-08-12 20:03:49 +00:00
|
|
|
++c;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
}
|
2016-09-13 01:25:08 +00:00
|
|
|
auto beginAfterControlAndSpace = c;
|
2016-09-15 18:12:09 +00:00
|
|
|
|
2016-08-12 20:03:49 +00:00
|
|
|
enum class State : uint8_t {
|
|
|
|
SchemeStart,
|
|
|
|
Scheme,
|
|
|
|
NoScheme,
|
|
|
|
SpecialRelativeOrAuthority,
|
|
|
|
PathOrAuthority,
|
|
|
|
Relative,
|
|
|
|
RelativeSlash,
|
|
|
|
SpecialAuthoritySlashes,
|
|
|
|
SpecialAuthorityIgnoreSlashes,
|
2016-08-17 00:41:30 +00:00
|
|
|
AuthorityOrHost,
|
2016-08-12 20:03:49 +00:00
|
|
|
Host,
|
|
|
|
File,
|
|
|
|
FileSlash,
|
|
|
|
FileHost,
|
|
|
|
PathStart,
|
|
|
|
Path,
|
|
|
|
CannotBeABaseURLPath,
|
2016-09-30 18:46:28 +00:00
|
|
|
UTF8Query,
|
|
|
|
NonUTF8Query,
|
2016-08-12 20:03:49 +00:00
|
|
|
Fragment,
|
|
|
|
};
|
|
|
|
|
2016-10-07 19:03:13 +00:00
|
|
|
#define LOG_STATE(x) URL_PARSER_LOG("State %s, code point %c, parsed data <%s> size %zu", x, *c, parsedDataView(0, currentPosition(c)).utf8().data(), currentPosition(c))
|
|
|
|
#define LOG_FINAL_STATE(x) URL_PARSER_LOG("Final State: %s", x)
|
2016-08-12 20:03:49 +00:00
|
|
|
|
|
|
|
State state = State::SchemeStart;
|
2016-09-15 18:12:09 +00:00
|
|
|
while (!c.atEnd()) {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (UNLIKELY(isTabOrNewline(*c))) {
|
|
|
|
syntaxViolation(c);
|
2016-08-12 20:03:49 +00:00
|
|
|
++c;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case State::SchemeStart:
|
|
|
|
LOG_STATE("SchemeStart");
|
2016-08-17 00:41:30 +00:00
|
|
|
if (isASCIIAlpha(*c)) {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (UNLIKELY(isASCIIUpper(*c)))
|
|
|
|
syntaxViolation(c);
|
2016-09-23 23:40:46 +00:00
|
|
|
appendToASCIIBuffer(toASCIILower(*c));
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(c);
|
2016-09-21 18:00:19 +00:00
|
|
|
if (c.atEnd()) {
|
|
|
|
m_asciiBuffer.clear();
|
|
|
|
state = State::NoScheme;
|
|
|
|
c = beginAfterControlAndSpace;
|
2017-09-06 16:37:57 +00:00
|
|
|
break;
|
2016-09-21 18:00:19 +00:00
|
|
|
}
|
2016-08-12 20:03:49 +00:00
|
|
|
state = State::Scheme;
|
|
|
|
} else
|
|
|
|
state = State::NoScheme;
|
|
|
|
break;
|
|
|
|
case State::Scheme:
|
|
|
|
LOG_STATE("Scheme");
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (isValidSchemeCharacter(*c)) {
|
|
|
|
if (UNLIKELY(isASCIIUpper(*c)))
|
|
|
|
syntaxViolation(c);
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer(toASCIILower(*c));
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
} else if (*c == ':') {
|
2018-07-13 00:28:36 +00:00
|
|
|
unsigned schemeEnd = currentPosition(c);
|
|
|
|
if (schemeEnd > URL::maxSchemeLength) {
|
|
|
|
failure();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_url.m_schemeEnd = schemeEnd;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
StringView urlScheme = parsedDataView(0, m_url.m_schemeEnd);
|
|
|
|
appendToASCIIBuffer(':');
|
2016-10-05 18:25:02 +00:00
|
|
|
switch (scheme(urlScheme)) {
|
|
|
|
case Scheme::File:
|
2016-09-09 01:32:18 +00:00
|
|
|
m_urlIsSpecial = true;
|
2017-02-24 16:45:32 +00:00
|
|
|
m_urlIsFile = true;
|
2016-08-12 20:03:49 +00:00
|
|
|
state = State::File;
|
2016-09-03 00:32:49 +00:00
|
|
|
++c;
|
|
|
|
break;
|
2016-10-05 18:25:02 +00:00
|
|
|
case Scheme::WS:
|
|
|
|
case Scheme::WSS:
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
nonUTF8QueryEncoding = nullptr;
|
2016-09-09 01:32:18 +00:00
|
|
|
m_urlIsSpecial = true;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (base.protocolIs(urlScheme))
|
2016-08-12 20:03:49 +00:00
|
|
|
state = State::SpecialRelativeOrAuthority;
|
|
|
|
else
|
|
|
|
state = State::SpecialAuthoritySlashes;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
++c;
|
2016-10-05 18:25:02 +00:00
|
|
|
break;
|
|
|
|
case Scheme::HTTP:
|
|
|
|
case Scheme::HTTPS:
|
|
|
|
m_url.m_protocolIsInHTTPFamily = true;
|
|
|
|
FALLTHROUGH;
|
|
|
|
case Scheme::FTP:
|
|
|
|
m_urlIsSpecial = true;
|
|
|
|
if (base.protocolIs(urlScheme))
|
|
|
|
state = State::SpecialRelativeOrAuthority;
|
|
|
|
else
|
|
|
|
state = State::SpecialAuthoritySlashes;
|
|
|
|
++c;
|
|
|
|
break;
|
|
|
|
case Scheme::NonSpecial:
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
nonUTF8QueryEncoding = nullptr;
|
2016-09-09 17:06:24 +00:00
|
|
|
auto maybeSlash = c;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(maybeSlash);
|
2016-09-15 18:12:09 +00:00
|
|
|
if (!maybeSlash.atEnd() && *maybeSlash == '/') {
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('/');
|
2016-09-12 18:10:24 +00:00
|
|
|
c = maybeSlash;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
state = State::PathOrAuthority;
|
2016-09-09 17:06:24 +00:00
|
|
|
ASSERT(*c == '/');
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
++c;
|
|
|
|
m_url.m_userStart = currentPosition(c);
|
2016-09-09 17:06:24 +00:00
|
|
|
} else {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
++c;
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_userStart = currentPosition(c);
|
2016-09-20 18:46:26 +00:00
|
|
|
m_url.m_userEnd = m_url.m_userStart;
|
|
|
|
m_url.m_passwordEnd = m_url.m_userStart;
|
|
|
|
m_url.m_hostEnd = m_url.m_userStart;
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-09-09 17:06:24 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_userStart;
|
2016-09-10 02:06:39 +00:00
|
|
|
m_url.m_cannotBeABaseURL = true;
|
2016-09-09 17:06:24 +00:00
|
|
|
state = State::CannotBeABaseURLPath;
|
|
|
|
}
|
2016-10-05 18:25:02 +00:00
|
|
|
break;
|
2016-09-09 17:06:24 +00:00
|
|
|
}
|
2016-09-12 22:36:14 +00:00
|
|
|
break;
|
2016-08-12 20:03:49 +00:00
|
|
|
} else {
|
2016-09-16 20:35:16 +00:00
|
|
|
m_asciiBuffer.clear();
|
2016-08-12 20:03:49 +00:00
|
|
|
state = State::NoScheme;
|
2016-09-13 01:25:08 +00:00
|
|
|
c = beginAfterControlAndSpace;
|
2016-08-28 05:55:17 +00:00
|
|
|
break;
|
2016-08-12 20:03:49 +00:00
|
|
|
}
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(c);
|
2016-09-15 18:12:09 +00:00
|
|
|
if (c.atEnd()) {
|
2016-09-16 20:35:16 +00:00
|
|
|
m_asciiBuffer.clear();
|
2016-08-28 05:55:17 +00:00
|
|
|
state = State::NoScheme;
|
2016-09-13 01:25:08 +00:00
|
|
|
c = beginAfterControlAndSpace;
|
2016-08-28 05:55:17 +00:00
|
|
|
}
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
|
|
|
case State::NoScheme:
|
|
|
|
LOG_STATE("NoScheme");
|
2016-09-23 20:58:03 +00:00
|
|
|
if (!base.isValid() || (base.m_cannotBeABaseURL && *c != '#')) {
|
|
|
|
failure();
|
|
|
|
return;
|
|
|
|
}
|
2016-09-10 02:06:39 +00:00
|
|
|
if (base.m_cannotBeABaseURL && *c == '#') {
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
copyURLPartsUntil(base, URLPart::QueryEnd, c, nonUTF8QueryEncoding);
|
2016-09-10 02:06:39 +00:00
|
|
|
state = State::Fragment;
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('#');
|
2016-09-10 02:06:39 +00:00
|
|
|
++c;
|
|
|
|
break;
|
|
|
|
}
|
2016-09-18 08:01:11 +00:00
|
|
|
if (!base.protocolIs("file")) {
|
2016-08-28 05:55:17 +00:00
|
|
|
state = State::Relative;
|
2016-09-10 02:06:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
state = State::File;
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
|
|
|
case State::SpecialRelativeOrAuthority:
|
|
|
|
LOG_STATE("SpecialRelativeOrAuthority");
|
|
|
|
if (*c == '/') {
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('/');
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(c);
|
2016-09-23 20:58:03 +00:00
|
|
|
if (c.atEnd()) {
|
|
|
|
failure();
|
|
|
|
return;
|
|
|
|
}
|
2016-08-12 20:03:49 +00:00
|
|
|
if (*c == '/') {
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('/');
|
2016-08-12 20:03:49 +00:00
|
|
|
state = State::SpecialAuthorityIgnoreSlashes;
|
|
|
|
++c;
|
2016-09-20 18:31:27 +00:00
|
|
|
} else
|
|
|
|
state = State::RelativeSlash;
|
2016-08-12 20:03:49 +00:00
|
|
|
} else
|
|
|
|
state = State::Relative;
|
|
|
|
break;
|
|
|
|
case State::PathOrAuthority:
|
|
|
|
LOG_STATE("PathOrAuthority");
|
2016-08-28 05:55:17 +00:00
|
|
|
if (*c == '/') {
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('/');
|
2016-08-28 05:55:17 +00:00
|
|
|
state = State::AuthorityOrHost;
|
2016-09-29 18:18:04 +00:00
|
|
|
advance(c);
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
m_url.m_userStart = currentPosition(c);
|
2016-09-01 21:50:32 +00:00
|
|
|
authorityOrHostBegin = c;
|
2016-09-20 18:46:26 +00:00
|
|
|
} else {
|
2016-11-16 22:53:48 +00:00
|
|
|
ASSERT(parsedDataView(currentPosition(c) - 1) == '/');
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_userStart = currentPosition(c) - 1;
|
2016-09-20 18:46:26 +00:00
|
|
|
m_url.m_userEnd = m_url.m_userStart;
|
|
|
|
m_url.m_passwordEnd = m_url.m_userStart;
|
|
|
|
m_url.m_hostEnd = m_url.m_userStart;
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-09-20 18:46:26 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
|
2016-08-28 05:55:17 +00:00
|
|
|
state = State::Path;
|
2016-09-20 18:46:26 +00:00
|
|
|
}
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
|
|
|
case State::Relative:
|
|
|
|
LOG_STATE("Relative");
|
2016-08-28 05:55:17 +00:00
|
|
|
switch (*c) {
|
|
|
|
case '/':
|
|
|
|
case '\\':
|
|
|
|
state = State::RelativeSlash;
|
|
|
|
++c;
|
|
|
|
break;
|
|
|
|
case '?':
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
copyURLPartsUntil(base, URLPart::PathEnd, c, nonUTF8QueryEncoding);
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('?');
|
2016-08-28 05:55:17 +00:00
|
|
|
++c;
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
if (nonUTF8QueryEncoding) {
|
2016-09-30 18:46:28 +00:00
|
|
|
queryBegin = c;
|
|
|
|
state = State::NonUTF8Query;
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
} else
|
|
|
|
state = State::UTF8Query;
|
2016-08-28 05:55:17 +00:00
|
|
|
break;
|
|
|
|
case '#':
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
copyURLPartsUntil(base, URLPart::QueryEnd, c, nonUTF8QueryEncoding);
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('#');
|
2016-08-28 05:55:17 +00:00
|
|
|
state = State::Fragment;
|
|
|
|
++c;
|
|
|
|
break;
|
|
|
|
default:
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
copyURLPartsUntil(base, URLPart::PathAfterLastSlash, c, nonUTF8QueryEncoding);
|
2020-10-03 21:17:06 +00:00
|
|
|
if ((currentPosition(c) && parsedDataView(currentPosition(c) - 1) != '/')
|
|
|
|
|| (base.host().isEmpty() && base.path().isEmpty())) {
|
2016-12-08 22:42:18 +00:00
|
|
|
appendToASCIIBuffer('/');
|
|
|
|
m_url.m_pathAfterLastSlash = currentPosition(c);
|
|
|
|
}
|
2016-08-28 05:55:17 +00:00
|
|
|
state = State::Path;
|
|
|
|
break;
|
|
|
|
}
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
|
|
|
case State::RelativeSlash:
|
|
|
|
LOG_STATE("RelativeSlash");
|
2016-08-28 05:55:17 +00:00
|
|
|
if (*c == '/' || *c == '\\') {
|
|
|
|
++c;
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
copyURLPartsUntil(base, URLPart::SchemeEnd, c, nonUTF8QueryEncoding);
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer("://", 3);
|
2017-02-25 00:36:19 +00:00
|
|
|
if (m_urlIsSpecial)
|
|
|
|
state = State::SpecialAuthorityIgnoreSlashes;
|
|
|
|
else {
|
|
|
|
m_url.m_userStart = currentPosition(c);
|
|
|
|
state = State::AuthorityOrHost;
|
|
|
|
authorityOrHostBegin = c;
|
|
|
|
}
|
2016-08-28 05:55:17 +00:00
|
|
|
} else {
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
copyURLPartsUntil(base, URLPart::PortEnd, c, nonUTF8QueryEncoding);
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('/');
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_pathAfterLastSlash = base.m_hostEnd + base.m_portLength + 1;
|
2016-08-28 05:55:17 +00:00
|
|
|
state = State::Path;
|
|
|
|
}
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
|
|
|
case State::SpecialAuthoritySlashes:
|
|
|
|
LOG_STATE("SpecialAuthoritySlashes");
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (LIKELY(*c == '/' || *c == '\\')) {
|
|
|
|
if (UNLIKELY(*c == '\\'))
|
|
|
|
syntaxViolation(c);
|
|
|
|
appendToASCIIBuffer('/');
|
|
|
|
advance(c);
|
|
|
|
if (LIKELY(!c.atEnd() && (*c == '/' || *c == '\\'))) {
|
|
|
|
if (UNLIKELY(*c == '\\'))
|
|
|
|
syntaxViolation(c);
|
2016-08-12 20:03:49 +00:00
|
|
|
++c;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
appendToASCIIBuffer('/');
|
|
|
|
} else {
|
|
|
|
syntaxViolation(c);
|
|
|
|
appendToASCIIBuffer('/');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
syntaxViolation(c);
|
|
|
|
appendToASCIIBuffer("//", 2);
|
2016-08-28 05:55:17 +00:00
|
|
|
}
|
|
|
|
state = State::SpecialAuthorityIgnoreSlashes;
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
|
|
|
case State::SpecialAuthorityIgnoreSlashes:
|
|
|
|
LOG_STATE("SpecialAuthorityIgnoreSlashes");
|
2016-08-28 05:55:17 +00:00
|
|
|
if (*c == '/' || *c == '\\') {
|
2016-09-28 21:14:44 +00:00
|
|
|
syntaxViolation(c);
|
2016-08-17 00:41:30 +00:00
|
|
|
++c;
|
2016-09-28 21:14:44 +00:00
|
|
|
} else {
|
|
|
|
m_url.m_userStart = currentPosition(c);
|
|
|
|
state = State::AuthorityOrHost;
|
|
|
|
authorityOrHostBegin = c;
|
2016-08-28 05:55:17 +00:00
|
|
|
}
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
2016-08-17 00:41:30 +00:00
|
|
|
case State::AuthorityOrHost:
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
do {
|
|
|
|
LOG_STATE("AuthorityOrHost");
|
2016-09-09 17:56:10 +00:00
|
|
|
if (*c == '@') {
|
2016-09-20 18:34:19 +00:00
|
|
|
auto lastAt = c;
|
|
|
|
auto findLastAt = c;
|
|
|
|
while (!findLastAt.atEnd()) {
|
2016-10-07 19:03:13 +00:00
|
|
|
URL_PARSER_LOG("Finding last @: %c", *findLastAt);
|
2016-09-20 18:34:19 +00:00
|
|
|
if (*findLastAt == '@')
|
|
|
|
lastAt = findLastAt;
|
2016-09-28 00:25:51 +00:00
|
|
|
bool isSlash = *findLastAt == '/' || (m_urlIsSpecial && *findLastAt == '\\');
|
|
|
|
if (isSlash || *findLastAt == '?' || *findLastAt == '#')
|
|
|
|
break;
|
2016-09-20 18:34:19 +00:00
|
|
|
++findLastAt;
|
|
|
|
}
|
2016-09-23 19:57:57 +00:00
|
|
|
parseAuthority(CodePointIterator<CharacterType>(authorityOrHostBegin, lastAt));
|
2016-09-20 18:34:19 +00:00
|
|
|
c = lastAt;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(c);
|
2016-09-09 17:56:10 +00:00
|
|
|
authorityOrHostBegin = c;
|
|
|
|
state = State::Host;
|
2016-09-14 19:34:53 +00:00
|
|
|
m_hostHasPercentOrNonASCII = false;
|
2016-09-09 17:56:10 +00:00
|
|
|
break;
|
2016-09-06 18:16:07 +00:00
|
|
|
}
|
2016-09-09 17:56:10 +00:00
|
|
|
bool isSlash = *c == '/' || (m_urlIsSpecial && *c == '\\');
|
|
|
|
if (isSlash || *c == '?' || *c == '#') {
|
2016-10-04 21:20:54 +00:00
|
|
|
auto iterator = CodePointIterator<CharacterType>(authorityOrHostBegin, c);
|
|
|
|
if (iterator.atEnd()) {
|
2017-02-16 23:13:45 +00:00
|
|
|
if (m_urlIsSpecial)
|
|
|
|
return failure();
|
2016-11-10 00:30:31 +00:00
|
|
|
m_url.m_userEnd = currentPosition(c);
|
|
|
|
m_url.m_passwordEnd = m_url.m_userEnd;
|
|
|
|
m_url.m_hostEnd = m_url.m_userEnd;
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-11-10 00:30:31 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_userEnd;
|
2016-10-04 21:20:54 +00:00
|
|
|
} else {
|
|
|
|
m_url.m_userEnd = currentPosition(authorityOrHostBegin);
|
|
|
|
m_url.m_passwordEnd = m_url.m_userEnd;
|
2016-10-13 21:01:58 +00:00
|
|
|
if (!parseHostAndPort(iterator)) {
|
2016-10-04 21:20:54 +00:00
|
|
|
failure();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (UNLIKELY(!isSlash)) {
|
2017-01-23 21:30:32 +00:00
|
|
|
if (m_urlIsSpecial) {
|
|
|
|
syntaxViolation(c);
|
|
|
|
appendToASCIIBuffer('/');
|
|
|
|
}
|
2016-10-04 21:20:54 +00:00
|
|
|
m_url.m_pathAfterLastSlash = currentPosition(c);
|
|
|
|
}
|
2016-09-09 17:56:10 +00:00
|
|
|
}
|
|
|
|
state = State::Path;
|
|
|
|
break;
|
|
|
|
}
|
2016-09-14 19:34:53 +00:00
|
|
|
if (isPercentOrNonASCII(*c))
|
|
|
|
m_hostHasPercentOrNonASCII = true;
|
2016-09-09 17:56:10 +00:00
|
|
|
++c;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
} while (!c.atEnd());
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
2016-08-17 00:41:30 +00:00
|
|
|
case State::Host:
|
2016-09-29 18:18:04 +00:00
|
|
|
do {
|
|
|
|
LOG_STATE("Host");
|
|
|
|
if (*c == '/' || *c == '?' || *c == '#') {
|
2016-10-13 21:01:58 +00:00
|
|
|
if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c))) {
|
2016-09-29 18:18:04 +00:00
|
|
|
failure();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (*c == '?' || *c == '#') {
|
|
|
|
syntaxViolation(c);
|
|
|
|
appendToASCIIBuffer('/');
|
|
|
|
m_url.m_pathAfterLastSlash = currentPosition(c);
|
|
|
|
}
|
|
|
|
state = State::Path;
|
|
|
|
break;
|
2016-09-28 21:14:44 +00:00
|
|
|
}
|
2016-09-29 18:18:04 +00:00
|
|
|
if (isPercentOrNonASCII(*c))
|
|
|
|
m_hostHasPercentOrNonASCII = true;
|
|
|
|
++c;
|
|
|
|
} while (!c.atEnd());
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
|
|
|
case State::File:
|
|
|
|
LOG_STATE("File");
|
2016-09-03 00:32:49 +00:00
|
|
|
switch (*c) {
|
|
|
|
case '\\':
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(c);
|
|
|
|
FALLTHROUGH;
|
|
|
|
case '/':
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('/');
|
2016-09-03 00:32:49 +00:00
|
|
|
state = State::FileSlash;
|
|
|
|
++c;
|
|
|
|
break;
|
|
|
|
case '?':
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(c);
|
2016-10-04 21:22:34 +00:00
|
|
|
if (base.isValid() && base.protocolIs("file")) {
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
copyURLPartsUntil(base, URLPart::PathEnd, c, nonUTF8QueryEncoding);
|
2016-10-04 21:22:34 +00:00
|
|
|
appendToASCIIBuffer('?');
|
|
|
|
++c;
|
|
|
|
} else {
|
|
|
|
appendToASCIIBuffer("///?", 4);
|
|
|
|
++c;
|
|
|
|
m_url.m_userStart = currentPosition(c) - 2;
|
|
|
|
m_url.m_userEnd = m_url.m_userStart;
|
|
|
|
m_url.m_passwordEnd = m_url.m_userStart;
|
|
|
|
m_url.m_hostEnd = m_url.m_userStart;
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-10-04 21:22:34 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
|
|
|
|
m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
}
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
if (nonUTF8QueryEncoding) {
|
2016-09-30 18:46:28 +00:00
|
|
|
queryBegin = c;
|
|
|
|
state = State::NonUTF8Query;
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
} else
|
|
|
|
state = State::UTF8Query;
|
2016-09-03 00:32:49 +00:00
|
|
|
break;
|
|
|
|
case '#':
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(c);
|
2016-10-03 21:31:15 +00:00
|
|
|
if (base.isValid() && base.protocolIs("file")) {
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
copyURLPartsUntil(base, URLPart::QueryEnd, c, nonUTF8QueryEncoding);
|
2016-10-03 21:31:15 +00:00
|
|
|
appendToASCIIBuffer('#');
|
|
|
|
} else {
|
|
|
|
appendToASCIIBuffer("///#", 4);
|
|
|
|
m_url.m_userStart = currentPosition(c) - 2;
|
|
|
|
m_url.m_userEnd = m_url.m_userStart;
|
|
|
|
m_url.m_passwordEnd = m_url.m_userStart;
|
|
|
|
m_url.m_hostEnd = m_url.m_userStart;
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-10-03 21:31:15 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
|
|
|
|
m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
}
|
2016-09-03 00:32:49 +00:00
|
|
|
state = State::Fragment;
|
|
|
|
++c;
|
|
|
|
break;
|
|
|
|
default:
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(c);
|
2016-09-23 19:57:57 +00:00
|
|
|
if (base.isValid() && base.protocolIs("file") && shouldCopyFileURL(c))
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
copyURLPartsUntil(base, URLPart::PathAfterLastSlash, c, nonUTF8QueryEncoding);
|
2016-09-06 18:16:07 +00:00
|
|
|
else {
|
2020-10-02 20:59:11 +00:00
|
|
|
bool copiedHost = false;
|
|
|
|
if (base.isValid() && base.protocolIs("file")) {
|
|
|
|
if (base.host().isEmpty()) {
|
|
|
|
copyURLPartsUntil(base, URLPart::SchemeEnd, c, nonUTF8QueryEncoding);
|
|
|
|
appendToASCIIBuffer(":///", 4);
|
|
|
|
} else {
|
|
|
|
copyURLPartsUntil(base, URLPart::PortEnd, c, nonUTF8QueryEncoding);
|
|
|
|
appendToASCIIBuffer('/');
|
|
|
|
copiedHost = true;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
appendToASCIIBuffer("///", 3);
|
|
|
|
if (!copiedHost) {
|
|
|
|
m_url.m_userStart = currentPosition(c) - 1;
|
|
|
|
m_url.m_userEnd = m_url.m_userStart;
|
|
|
|
m_url.m_passwordEnd = m_url.m_userStart;
|
|
|
|
m_url.m_hostEnd = m_url.m_userStart;
|
|
|
|
m_url.m_portLength = 0;
|
|
|
|
}
|
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_hostEnd + 1;
|
2016-09-03 00:32:49 +00:00
|
|
|
}
|
2020-10-05 14:43:04 +00:00
|
|
|
if (isWindowsDriveLetter(c))
|
|
|
|
appendWindowsDriveLetter(c);
|
2016-09-03 00:32:49 +00:00
|
|
|
state = State::Path;
|
|
|
|
break;
|
|
|
|
}
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
|
|
|
case State::FileSlash:
|
|
|
|
LOG_STATE("FileSlash");
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (LIKELY(*c == '/' || *c == '\\')) {
|
|
|
|
if (UNLIKELY(*c == '\\'))
|
|
|
|
syntaxViolation(c);
|
2020-10-02 20:59:11 +00:00
|
|
|
if (base.isValid() && base.protocolIs("file")) {
|
|
|
|
copyURLPartsUntil(base, URLPart::SchemeEnd, c, nonUTF8QueryEncoding);
|
|
|
|
appendToASCIIBuffer(":/", 2);
|
|
|
|
}
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('/');
|
2016-09-29 18:18:04 +00:00
|
|
|
advance(c);
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_userStart = currentPosition(c);
|
2016-09-03 00:32:49 +00:00
|
|
|
m_url.m_userEnd = m_url.m_userStart;
|
|
|
|
m_url.m_passwordEnd = m_url.m_userStart;
|
|
|
|
m_url.m_hostEnd = m_url.m_userStart;
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-09-03 00:32:49 +00:00
|
|
|
authorityOrHostBegin = c;
|
|
|
|
state = State::FileHost;
|
|
|
|
break;
|
|
|
|
}
|
2020-10-02 20:59:11 +00:00
|
|
|
{
|
|
|
|
bool copiedHost = false;
|
|
|
|
if (base.isValid() && base.protocolIs("file")) {
|
|
|
|
if (base.host().isEmpty()) {
|
|
|
|
copyURLPartsUntil(base, URLPart::SchemeEnd, c, nonUTF8QueryEncoding);
|
|
|
|
appendToASCIIBuffer(":///", 4);
|
|
|
|
} else {
|
|
|
|
copyURLPartsUntil(base, URLPart::PortEnd, c, nonUTF8QueryEncoding);
|
|
|
|
appendToASCIIBuffer('/');
|
|
|
|
copiedHost = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
syntaxViolation(c);
|
|
|
|
appendToASCIIBuffer("//", 2);
|
|
|
|
}
|
|
|
|
if (!copiedHost) {
|
|
|
|
m_url.m_userStart = currentPosition(c) - 1;
|
|
|
|
m_url.m_userEnd = m_url.m_userStart;
|
|
|
|
m_url.m_passwordEnd = m_url.m_userStart;
|
|
|
|
m_url.m_hostEnd = m_url.m_userStart;
|
|
|
|
m_url.m_portLength = 0;
|
|
|
|
}
|
|
|
|
}
|
2017-03-06 22:55:33 +00:00
|
|
|
if (isWindowsDriveLetter(c)) {
|
2016-09-28 00:31:44 +00:00
|
|
|
appendWindowsDriveLetter(c);
|
2020-10-02 20:59:11 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_hostEnd + 1;
|
2017-03-06 22:55:33 +00:00
|
|
|
} else if (copyBaseWindowsDriveLetter(base)) {
|
|
|
|
appendToASCIIBuffer('/');
|
2020-10-02 20:59:11 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_hostEnd + 4;
|
2017-03-06 22:55:33 +00:00
|
|
|
} else
|
2020-10-02 20:59:11 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_hostEnd + 1;
|
2016-09-03 00:32:49 +00:00
|
|
|
state = State::Path;
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
|
|
|
case State::FileHost:
|
2016-09-29 18:18:04 +00:00
|
|
|
do {
|
|
|
|
LOG_STATE("FileHost");
|
|
|
|
if (isSlashQuestionOrHash(*c)) {
|
2016-10-03 22:55:46 +00:00
|
|
|
bool windowsQuirk = takesTwoAdvancesUntilEnd(CodePointIterator<CharacterType>(authorityOrHostBegin, c))
|
|
|
|
&& isWindowsDriveLetter(authorityOrHostBegin);
|
2016-09-29 18:18:04 +00:00
|
|
|
if (windowsQuirk) {
|
|
|
|
syntaxViolation(authorityOrHostBegin);
|
|
|
|
appendToASCIIBuffer('/');
|
|
|
|
appendWindowsDriveLetter(authorityOrHostBegin);
|
|
|
|
}
|
|
|
|
if (windowsQuirk || authorityOrHostBegin == c) {
|
2016-11-16 22:53:48 +00:00
|
|
|
ASSERT(windowsQuirk || parsedDataView(currentPosition(c) - 1) == '/');
|
2016-09-29 18:18:04 +00:00
|
|
|
if (UNLIKELY(*c == '?')) {
|
|
|
|
syntaxViolation(c);
|
|
|
|
appendToASCIIBuffer("/?", 2);
|
|
|
|
++c;
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
if (nonUTF8QueryEncoding) {
|
2016-09-30 18:46:28 +00:00
|
|
|
queryBegin = c;
|
|
|
|
state = State::NonUTF8Query;
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
} else
|
|
|
|
state = State::UTF8Query;
|
2016-09-29 18:18:04 +00:00
|
|
|
m_url.m_pathAfterLastSlash = currentPosition(c) - 1;
|
|
|
|
m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (UNLIKELY(*c == '#')) {
|
|
|
|
syntaxViolation(c);
|
|
|
|
appendToASCIIBuffer("/#", 2);
|
|
|
|
++c;
|
|
|
|
m_url.m_pathAfterLastSlash = currentPosition(c) - 1;
|
|
|
|
m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
state = State::Fragment;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
state = State::Path;
|
2016-09-03 00:32:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-10-13 21:01:58 +00:00
|
|
|
if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c))) {
|
2016-09-29 18:18:04 +00:00
|
|
|
failure();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (UNLIKELY(isLocalhost(parsedDataView(m_url.m_passwordEnd, currentPosition(c) - m_url.m_passwordEnd)))) {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(c);
|
2016-09-29 18:18:04 +00:00
|
|
|
m_asciiBuffer.shrink(m_url.m_passwordEnd);
|
|
|
|
m_url.m_hostEnd = currentPosition(c);
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-09-03 00:32:49 +00:00
|
|
|
}
|
2016-09-29 18:18:04 +00:00
|
|
|
|
|
|
|
state = State::PathStart;
|
2016-09-03 00:32:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-09-29 18:18:04 +00:00
|
|
|
if (isPercentOrNonASCII(*c))
|
|
|
|
m_hostHasPercentOrNonASCII = true;
|
|
|
|
++c;
|
|
|
|
} while (!c.atEnd());
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
|
|
|
case State::PathStart:
|
|
|
|
LOG_STATE("PathStart");
|
2017-10-30 21:55:28 +00:00
|
|
|
if (*c != '/' && *c != '\\') {
|
|
|
|
syntaxViolation(c);
|
|
|
|
appendToASCIIBuffer('/');
|
|
|
|
}
|
|
|
|
m_url.m_pathAfterLastSlash = currentPosition(c);
|
2016-08-12 20:03:49 +00:00
|
|
|
state = State::Path;
|
2016-08-28 05:55:17 +00:00
|
|
|
break;
|
2016-08-12 20:03:49 +00:00
|
|
|
case State::Path:
|
|
|
|
LOG_STATE("Path");
|
2016-09-09 01:32:18 +00:00
|
|
|
if (*c == '/' || (m_urlIsSpecial && *c == '\\')) {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (UNLIKELY(m_urlIsSpecial && *c == '\\'))
|
|
|
|
syntaxViolation(c);
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('/');
|
2016-08-12 20:03:49 +00:00
|
|
|
++c;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
m_url.m_pathAfterLastSlash = currentPosition(c);
|
2016-09-01 20:33:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-11-16 22:53:48 +00:00
|
|
|
if (UNLIKELY(currentPosition(c) && parsedDataView(currentPosition(c) - 1) == '/')) {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (UNLIKELY(isDoubleDotPathSegment(c))) {
|
|
|
|
syntaxViolation(c);
|
2016-09-15 18:12:09 +00:00
|
|
|
consumeDoubleDotPathSegment(c);
|
2016-09-01 20:33:31 +00:00
|
|
|
popPath();
|
|
|
|
break;
|
|
|
|
}
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (UNLIKELY(isSingleDotPathSegment(c))) {
|
|
|
|
syntaxViolation(c);
|
2016-09-15 18:12:09 +00:00
|
|
|
consumeSingleDotPathSegment(c);
|
2016-08-12 23:12:46 +00:00
|
|
|
break;
|
2016-08-12 20:03:49 +00:00
|
|
|
}
|
2016-09-01 20:33:31 +00:00
|
|
|
}
|
|
|
|
if (*c == '?') {
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_pathEnd = currentPosition(c);
|
2016-09-30 18:46:28 +00:00
|
|
|
appendToASCIIBuffer('?');
|
|
|
|
++c;
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
if (nonUTF8QueryEncoding) {
|
2016-09-30 18:46:28 +00:00
|
|
|
queryBegin = c;
|
|
|
|
state = State::NonUTF8Query;
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
} else
|
|
|
|
state = State::UTF8Query;
|
2016-08-28 05:55:17 +00:00
|
|
|
break;
|
2016-09-01 20:33:31 +00:00
|
|
|
}
|
|
|
|
if (*c == '#') {
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_pathEnd = currentPosition(c);
|
2016-09-01 20:33:31 +00:00
|
|
|
m_url.m_queryEnd = m_url.m_pathEnd;
|
2016-08-12 20:03:49 +00:00
|
|
|
state = State::Fragment;
|
2016-08-28 05:55:17 +00:00
|
|
|
break;
|
2016-08-12 20:03:49 +00:00
|
|
|
}
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
utf8PercentEncode<isInDefaultEncodeSet>(c);
|
2016-08-12 20:03:49 +00:00
|
|
|
++c;
|
|
|
|
break;
|
|
|
|
case State::CannotBeABaseURLPath:
|
|
|
|
LOG_STATE("CannotBeABaseURLPath");
|
2016-08-29 21:15:27 +00:00
|
|
|
if (*c == '?') {
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_pathEnd = currentPosition(c);
|
2016-09-30 18:46:28 +00:00
|
|
|
appendToASCIIBuffer('?');
|
|
|
|
++c;
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
if (nonUTF8QueryEncoding) {
|
2016-09-30 18:46:28 +00:00
|
|
|
queryBegin = c;
|
|
|
|
state = State::NonUTF8Query;
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
} else
|
|
|
|
state = State::UTF8Query;
|
2016-08-29 21:15:27 +00:00
|
|
|
} else if (*c == '#') {
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_pathEnd = currentPosition(c);
|
2016-08-29 21:15:27 +00:00
|
|
|
m_url.m_queryEnd = m_url.m_pathEnd;
|
|
|
|
state = State::Fragment;
|
2016-09-21 21:16:15 +00:00
|
|
|
} else if (*c == '/') {
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('/');
|
2016-09-21 21:16:15 +00:00
|
|
|
++c;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
m_url.m_pathAfterLastSlash = currentPosition(c);
|
2016-08-29 21:15:27 +00:00
|
|
|
} else {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
utf8PercentEncode<isInSimpleEncodeSet>(c);
|
2016-08-29 21:15:27 +00:00
|
|
|
++c;
|
|
|
|
}
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
2016-09-30 18:46:28 +00:00
|
|
|
case State::UTF8Query:
|
|
|
|
LOG_STATE("UTF8Query");
|
|
|
|
ASSERT(queryBegin == CodePointIterator<CharacterType>());
|
2016-08-12 20:03:49 +00:00
|
|
|
if (*c == '#') {
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_queryEnd = currentPosition(c);
|
2016-08-12 20:03:49 +00:00
|
|
|
state = State::Fragment;
|
2016-08-28 05:55:17 +00:00
|
|
|
break;
|
2016-08-12 20:03:49 +00:00
|
|
|
}
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
ASSERT(!nonUTF8QueryEncoding);
|
|
|
|
utf8QueryEncode(c);
|
2016-08-12 20:03:49 +00:00
|
|
|
++c;
|
|
|
|
break;
|
2016-09-30 18:46:28 +00:00
|
|
|
case State::NonUTF8Query:
|
|
|
|
do {
|
|
|
|
LOG_STATE("NonUTF8Query");
|
|
|
|
ASSERT(queryBegin != CodePointIterator<CharacterType>());
|
|
|
|
if (*c == '#') {
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
encodeNonUTF8Query(queryBuffer, *nonUTF8QueryEncoding, CodePointIterator<CharacterType>(queryBegin, c));
|
2016-09-30 18:46:28 +00:00
|
|
|
m_url.m_queryEnd = currentPosition(c);
|
|
|
|
state = State::Fragment;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
appendCodePoint(queryBuffer, *c);
|
|
|
|
advance(c, queryBegin);
|
|
|
|
} while (!c.atEnd());
|
|
|
|
break;
|
2016-08-12 20:03:49 +00:00
|
|
|
case State::Fragment:
|
2016-10-11 18:28:50 +00:00
|
|
|
URL_PARSER_LOG("State Fragment");
|
2020-09-01 16:42:54 +00:00
|
|
|
utf8PercentEncode<isInFragmentEncodeSet>(c);
|
2016-10-11 18:28:50 +00:00
|
|
|
++c;
|
2016-08-12 20:03:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-08-17 00:41:30 +00:00
|
|
|
|
2016-08-12 23:12:46 +00:00
|
|
|
switch (state) {
|
|
|
|
case State::SchemeStart:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("SchemeStart");
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (!currentPosition(c) && base.isValid() && !base.m_cannotBeABaseURL) {
|
2016-09-23 20:58:03 +00:00
|
|
|
m_url = base;
|
2016-10-03 17:28:04 +00:00
|
|
|
m_url.removeFragmentIdentifier();
|
2016-09-23 20:58:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
failure();
|
|
|
|
return;
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::Scheme:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("Scheme");
|
2016-09-23 20:58:03 +00:00
|
|
|
failure();
|
|
|
|
return;
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::NoScheme:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("NoScheme");
|
2016-09-16 18:57:07 +00:00
|
|
|
RELEASE_ASSERT_NOT_REACHED();
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::SpecialRelativeOrAuthority:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("SpecialRelativeOrAuthority");
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
copyURLPartsUntil(base, URLPart::QueryEnd, c, nonUTF8QueryEncoding);
|
2016-08-17 00:41:30 +00:00
|
|
|
break;
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::PathOrAuthority:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("PathOrAuthority");
|
2016-09-21 18:02:52 +00:00
|
|
|
ASSERT(m_url.m_userStart);
|
2016-09-23 23:40:46 +00:00
|
|
|
ASSERT(m_url.m_userStart == currentPosition(c));
|
2016-11-16 22:53:48 +00:00
|
|
|
ASSERT(parsedDataView(currentPosition(c) - 1) == '/');
|
2016-09-21 18:02:52 +00:00
|
|
|
m_url.m_userStart--;
|
|
|
|
m_url.m_userEnd = m_url.m_userStart;
|
|
|
|
m_url.m_passwordEnd = m_url.m_userStart;
|
|
|
|
m_url.m_hostEnd = m_url.m_userStart;
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-09-21 18:02:52 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
|
2016-09-16 18:57:07 +00:00
|
|
|
m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
|
2016-08-17 00:41:30 +00:00
|
|
|
break;
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::Relative:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("Relative");
|
2016-10-03 17:28:04 +00:00
|
|
|
RELEASE_ASSERT_NOT_REACHED();
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::RelativeSlash:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("RelativeSlash");
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
copyURLPartsUntil(base, URLPart::PortEnd, c, nonUTF8QueryEncoding);
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('/');
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_hostEnd + m_url.m_portLength + 1;
|
2016-09-08 17:23:30 +00:00
|
|
|
m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
|
2016-08-17 00:41:30 +00:00
|
|
|
break;
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::SpecialAuthoritySlashes:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("SpecialAuthoritySlashes");
|
2020-10-03 18:39:27 +00:00
|
|
|
failure();
|
|
|
|
return;
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::SpecialAuthorityIgnoreSlashes:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("SpecialAuthorityIgnoreSlashes");
|
2016-09-23 20:58:03 +00:00
|
|
|
failure();
|
|
|
|
return;
|
2016-08-17 00:41:30 +00:00
|
|
|
case State::AuthorityOrHost:
|
|
|
|
LOG_FINAL_STATE("AuthorityOrHost");
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
m_url.m_userEnd = currentPosition(authorityOrHostBegin);
|
2016-08-17 00:41:30 +00:00
|
|
|
m_url.m_passwordEnd = m_url.m_userEnd;
|
2016-09-20 18:46:26 +00:00
|
|
|
if (authorityOrHostBegin.atEnd()) {
|
2016-10-04 21:20:54 +00:00
|
|
|
m_url.m_userEnd = m_url.m_userStart;
|
|
|
|
m_url.m_passwordEnd = m_url.m_userStart;
|
|
|
|
m_url.m_hostEnd = m_url.m_userStart;
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-11-10 00:30:31 +00:00
|
|
|
m_url.m_pathEnd = m_url.m_userStart;
|
2016-10-13 21:01:58 +00:00
|
|
|
} else if (!parseHostAndPort(authorityOrHostBegin)) {
|
2016-09-23 20:58:03 +00:00
|
|
|
failure();
|
|
|
|
return;
|
2016-10-04 21:20:54 +00:00
|
|
|
} else {
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
if (m_urlIsSpecial) {
|
|
|
|
syntaxViolation(c);
|
|
|
|
appendToASCIIBuffer('/');
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_pathEnd = m_url.m_hostEnd + m_url.m_portLength + 1;
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
} else
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_pathEnd = m_url.m_hostEnd + m_url.m_portLength;
|
2016-09-23 20:58:03 +00:00
|
|
|
}
|
2016-09-20 18:46:26 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_pathEnd;
|
|
|
|
m_url.m_queryEnd = m_url.m_pathEnd;
|
|
|
|
break;
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::Host:
|
2016-09-20 18:46:26 +00:00
|
|
|
LOG_FINAL_STATE("Host");
|
2016-10-13 21:01:58 +00:00
|
|
|
if (!parseHostAndPort(authorityOrHostBegin)) {
|
2016-09-23 20:58:03 +00:00
|
|
|
failure();
|
|
|
|
return;
|
|
|
|
}
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
if (m_urlIsSpecial) {
|
|
|
|
syntaxViolation(c);
|
|
|
|
appendToASCIIBuffer('/');
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_pathEnd = m_url.m_hostEnd + m_url.m_portLength + 1;
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
} else
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_pathEnd = m_url.m_hostEnd + m_url.m_portLength;
|
2016-08-17 00:41:30 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_pathEnd;
|
|
|
|
m_url.m_queryEnd = m_url.m_pathEnd;
|
2016-08-12 23:12:46 +00:00
|
|
|
break;
|
|
|
|
case State::File:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("File");
|
2016-09-21 20:19:07 +00:00
|
|
|
if (base.isValid() && base.protocolIs("file")) {
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
copyURLPartsUntil(base, URLPart::QueryEnd, c, nonUTF8QueryEncoding);
|
2017-03-03 21:50:07 +00:00
|
|
|
break;
|
2016-09-03 00:32:49 +00:00
|
|
|
}
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(c);
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer("///", 3);
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_userStart = currentPosition(c) - 1;
|
2016-09-03 00:32:49 +00:00
|
|
|
m_url.m_userEnd = m_url.m_userStart;
|
|
|
|
m_url.m_passwordEnd = m_url.m_userStart;
|
|
|
|
m_url.m_hostEnd = m_url.m_userStart;
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-09-03 00:32:49 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
|
|
|
|
m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
|
2016-08-17 00:41:30 +00:00
|
|
|
break;
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::FileSlash:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("FileSlash");
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(c);
|
2020-10-02 20:59:11 +00:00
|
|
|
{
|
|
|
|
bool copiedHost = false;
|
|
|
|
if (base.isValid() && base.protocolIs("file")) {
|
|
|
|
if (base.host().isEmpty()) {
|
|
|
|
copyURLPartsUntil(base, URLPart::SchemeEnd, c, nonUTF8QueryEncoding);
|
|
|
|
appendToASCIIBuffer(":/", 2);
|
|
|
|
} else {
|
|
|
|
copyURLPartsUntil(base, URLPart::PortEnd, c, nonUTF8QueryEncoding);
|
|
|
|
appendToASCIIBuffer('/');
|
|
|
|
copiedHost = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!copiedHost) {
|
|
|
|
m_url.m_userStart = currentPosition(c) + 1;
|
|
|
|
appendToASCIIBuffer("//", 2);
|
|
|
|
m_url.m_userEnd = m_url.m_userStart;
|
|
|
|
m_url.m_passwordEnd = m_url.m_userStart;
|
|
|
|
m_url.m_hostEnd = m_url.m_userStart;
|
|
|
|
m_url.m_portLength = 0;
|
|
|
|
}
|
|
|
|
}
|
2017-03-06 22:55:33 +00:00
|
|
|
if (copyBaseWindowsDriveLetter(base)) {
|
|
|
|
appendToASCIIBuffer('/');
|
2020-10-02 20:59:11 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_hostEnd + 4;
|
2017-03-06 22:55:33 +00:00
|
|
|
} else
|
2020-10-02 20:59:11 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_hostEnd + 1;
|
2016-09-03 00:32:49 +00:00
|
|
|
m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
|
2016-08-17 00:41:30 +00:00
|
|
|
break;
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::FileHost:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("FileHost");
|
2017-03-07 23:07:56 +00:00
|
|
|
if (takesTwoAdvancesUntilEnd(CodePointIterator<CharacterType>(authorityOrHostBegin, c))
|
|
|
|
&& isWindowsDriveLetter(authorityOrHostBegin)) {
|
|
|
|
syntaxViolation(authorityOrHostBegin);
|
|
|
|
appendToASCIIBuffer('/');
|
|
|
|
appendWindowsDriveLetter(authorityOrHostBegin);
|
|
|
|
m_url.m_pathAfterLastSlash = currentPosition(c);
|
|
|
|
m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-09-03 00:32:49 +00:00
|
|
|
if (authorityOrHostBegin == c) {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(c);
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('/');
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_userStart = currentPosition(c) - 1;
|
2016-09-03 00:32:49 +00:00
|
|
|
m_url.m_userEnd = m_url.m_userStart;
|
|
|
|
m_url.m_passwordEnd = m_url.m_userStart;
|
|
|
|
m_url.m_hostEnd = m_url.m_userStart;
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-09-03 00:32:49 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
|
|
|
|
m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-10-13 21:01:58 +00:00
|
|
|
if (!parseHostAndPort(CodePointIterator<CharacterType>(authorityOrHostBegin, c))) {
|
2016-09-23 20:58:03 +00:00
|
|
|
failure();
|
|
|
|
return;
|
|
|
|
}
|
2016-09-16 20:35:16 +00:00
|
|
|
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(c);
|
2016-09-29 18:18:04 +00:00
|
|
|
if (isLocalhost(parsedDataView(m_url.m_passwordEnd, currentPosition(c) - m_url.m_passwordEnd))) {
|
2016-09-16 20:35:16 +00:00
|
|
|
m_asciiBuffer.shrink(m_url.m_passwordEnd);
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_hostEnd = currentPosition(c);
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-09-03 00:32:49 +00:00
|
|
|
}
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('/');
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_pathAfterLastSlash = m_url.m_hostEnd + m_url.m_portLength + 1;
|
2016-09-09 21:29:47 +00:00
|
|
|
m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
|
|
|
|
m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
|
2016-08-17 00:41:30 +00:00
|
|
|
break;
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::PathStart:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("PathStart");
|
2016-09-16 18:57:07 +00:00
|
|
|
RELEASE_ASSERT_NOT_REACHED();
|
2016-08-12 23:12:46 +00:00
|
|
|
case State::Path:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("Path");
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_pathEnd = currentPosition(c);
|
2016-08-17 00:41:30 +00:00
|
|
|
m_url.m_queryEnd = m_url.m_pathEnd;
|
2016-08-12 23:12:46 +00:00
|
|
|
break;
|
|
|
|
case State::CannotBeABaseURLPath:
|
2016-08-17 00:41:30 +00:00
|
|
|
LOG_FINAL_STATE("CannotBeABaseURLPath");
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_pathEnd = currentPosition(c);
|
2016-08-29 21:15:27 +00:00
|
|
|
m_url.m_queryEnd = m_url.m_pathEnd;
|
2016-08-12 23:12:46 +00:00
|
|
|
break;
|
2016-09-30 18:46:28 +00:00
|
|
|
case State::UTF8Query:
|
|
|
|
LOG_FINAL_STATE("UTF8Query");
|
|
|
|
ASSERT(queryBegin == CodePointIterator<CharacterType>());
|
|
|
|
m_url.m_queryEnd = currentPosition(c);
|
|
|
|
break;
|
|
|
|
case State::NonUTF8Query:
|
|
|
|
LOG_FINAL_STATE("NonUTF8Query");
|
|
|
|
ASSERT(queryBegin != CodePointIterator<CharacterType>());
|
URLParser should use TextEncoding through an abstract class
https://bugs.webkit.org/show_bug.cgi?id=190027
Reviewed by Andy Estes.
Source/WebCore:
URLParser uses TextEncoding for one call to encode, which is only used for encoding the query of URLs in documents with non-UTF encodings.
There are 3 call sites that specify the TextEncoding to use from the Document, and even those call sites use a UTF encoding most of the time.
All other URL parsing is done using a well-optimized path which assumes UTF-8 encoding and uses macros from ICU headers, not a TextEncoding.
Moving the logic in this way breaks URL and URLParser's dependency on TextEncoding, which makes it possible to use in a lower-level project
without also moving TextEncoding, TextCodec, TextCodecICU, ThreadGlobalData, and the rest of WebCore and JavaScriptCore.
There is no observable change in behavior. There is now one virtual function call in a code path in URLParser that is not performance-sensitive,
and TextEncodings now have a vtable, which uses a few more bytes of memory total for WebKit.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContext::completeURL const):
* css/parser/CSSParserIdioms.cpp:
(WebCore::completeURL):
* dom/Document.cpp:
(WebCore::Document::completeURL const):
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
Move the call to encodingForFormSubmission from the URL constructor to the 3 call sites that specify the encoding from the Document.
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::encodingForURLParsing):
* loader/TextResourceDecoder.h:
* platform/URL.cpp:
(WebCore::URL::URL):
* platform/URL.h:
(WebCore::URLTextEncoding::~URLTextEncoding):
* platform/URLParser.cpp:
(WebCore::URLParser::encodeNonUTF8Query):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::encodeQuery): Deleted.
A pointer replaces the boolean isUTF8Encoding and the TextEncoding& which had a default value of UTF8Encoding.
Now the pointer being null means that we use UTF8, and the pointer being non-null means we use that encoding.
* platform/URLParser.h:
(WebCore::URLParser::URLParser):
* platform/text/TextEncoding.cpp:
(WebCore::UTF7Encoding):
(WebCore::TextEncoding::encodingForFormSubmissionOrURLParsing const):
(WebCore::ASCIIEncoding):
(WebCore::Latin1Encoding):
(WebCore::UTF16BigEndianEncoding):
(WebCore::UTF16LittleEndianEncoding):
(WebCore::UTF8Encoding):
(WebCore::WindowsLatin1Encoding):
(WebCore::TextEncoding::encodingForFormSubmission const): Deleted.
Use NeverDestroyed because TextEncoding now has a virtual destructor.
* platform/text/TextEncoding.h:
Rename encodingForFormSubmission to encodingForFormSubmissionOrURLParsing to make it more clear that we are intentionally using it for both.
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/205005@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 20:05:52 +00:00
|
|
|
encodeNonUTF8Query(queryBuffer, *nonUTF8QueryEncoding, CodePointIterator<CharacterType>(queryBegin, c));
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_queryEnd = currentPosition(c);
|
2016-08-12 23:12:46 +00:00
|
|
|
break;
|
|
|
|
case State::Fragment:
|
2016-10-11 18:28:50 +00:00
|
|
|
LOG_FINAL_STATE("Fragment");
|
|
|
|
break;
|
2016-08-12 23:12:46 +00:00
|
|
|
}
|
|
|
|
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (LIKELY(!m_didSeeSyntaxViolation)) {
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_string = m_inputString;
|
|
|
|
ASSERT(m_asciiBuffer.isEmpty());
|
2016-10-11 18:28:50 +00:00
|
|
|
} else
|
2016-09-21 03:10:57 +00:00
|
|
|
m_url.m_string = String::adopt(WTFMove(m_asciiBuffer));
|
2016-08-17 00:41:30 +00:00
|
|
|
m_url.m_isValid = true;
|
2020-10-02 20:59:11 +00:00
|
|
|
URL_PARSER_LOG("Parsed URL <%s>\n\n", m_url.m_string.utf8().data());
|
2016-08-17 00:41:30 +00:00
|
|
|
}
|
|
|
|
|
2016-09-23 19:57:57 +00:00
|
|
|
template<typename CharacterType>
|
2016-09-15 18:12:09 +00:00
|
|
|
void URLParser::parseAuthority(CodePointIterator<CharacterType> iterator)
|
2016-08-17 00:41:30 +00:00
|
|
|
{
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (UNLIKELY(iterator.atEnd())) {
|
|
|
|
syntaxViolation(iterator);
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_userEnd = currentPosition(iterator);
|
2016-09-08 22:15:07 +00:00
|
|
|
m_url.m_passwordEnd = m_url.m_userEnd;
|
|
|
|
return;
|
|
|
|
}
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
for (; !iterator.atEnd(); advance(iterator)) {
|
2016-08-17 00:41:30 +00:00
|
|
|
if (*iterator == ':') {
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_userEnd = currentPosition(iterator);
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
auto iteratorAtColon = iterator;
|
2016-09-28 21:16:22 +00:00
|
|
|
++iterator;
|
|
|
|
bool tabOrNewlineAfterColon = false;
|
|
|
|
while (UNLIKELY(!iterator.atEnd() && isTabOrNewline(*iterator))) {
|
|
|
|
tabOrNewlineAfterColon = true;
|
|
|
|
++iterator;
|
|
|
|
}
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (UNLIKELY(iterator.atEnd())) {
|
|
|
|
syntaxViolation(iteratorAtColon);
|
2016-09-08 22:15:07 +00:00
|
|
|
m_url.m_passwordEnd = m_url.m_userEnd;
|
|
|
|
if (m_url.m_userEnd > m_url.m_userStart)
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('@');
|
2016-09-08 22:15:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-09-28 21:16:22 +00:00
|
|
|
if (tabOrNewlineAfterColon)
|
|
|
|
syntaxViolation(iteratorAtColon);
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer(':');
|
2016-08-17 00:41:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-12-01 03:28:36 +00:00
|
|
|
utf8PercentEncode<WTF::isInUserInfoEncodeSet>(iterator);
|
2016-08-17 00:41:30 +00:00
|
|
|
}
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
for (; !iterator.atEnd(); advance(iterator))
|
2018-12-01 03:28:36 +00:00
|
|
|
utf8PercentEncode<WTF::isInUserInfoEncodeSet>(iterator);
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_passwordEnd = currentPosition(iterator);
|
2016-09-09 00:05:36 +00:00
|
|
|
if (!m_url.m_userEnd)
|
|
|
|
m_url.m_userEnd = m_url.m_passwordEnd;
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer('@');
|
2016-08-17 00:41:30 +00:00
|
|
|
}
|
|
|
|
|
2016-09-16 20:35:16 +00:00
|
|
|
template<typename UnsignedIntegerType>
|
2016-09-23 23:40:46 +00:00
|
|
|
void URLParser::appendNumberToASCIIBuffer(UnsignedIntegerType number)
|
2016-08-22 05:42:12 +00:00
|
|
|
{
|
2016-09-16 20:35:16 +00:00
|
|
|
LChar buf[sizeof(UnsignedIntegerType) * 3 + 1];
|
2017-06-06 22:09:44 +00:00
|
|
|
LChar* end = std::end(buf);
|
2016-09-16 20:35:16 +00:00
|
|
|
LChar* p = end;
|
|
|
|
do {
|
|
|
|
*--p = (number % 10) + '0';
|
|
|
|
number /= 10;
|
|
|
|
} while (number);
|
2016-09-23 23:40:46 +00:00
|
|
|
appendToASCIIBuffer(p, end - p);
|
2016-09-16 20:35:16 +00:00
|
|
|
}
|
|
|
|
|
2016-09-23 23:40:46 +00:00
|
|
|
void URLParser::serializeIPv4(IPv4Address address)
|
2016-09-16 20:35:16 +00:00
|
|
|
{
|
2016-09-23 23:40:46 +00:00
|
|
|
appendNumberToASCIIBuffer<uint8_t>(address >> 24);
|
|
|
|
appendToASCIIBuffer('.');
|
|
|
|
appendNumberToASCIIBuffer<uint8_t>(address >> 16);
|
|
|
|
appendToASCIIBuffer('.');
|
|
|
|
appendNumberToASCIIBuffer<uint8_t>(address >> 8);
|
|
|
|
appendToASCIIBuffer('.');
|
|
|
|
appendNumberToASCIIBuffer<uint8_t>(address);
|
2016-08-22 05:42:12 +00:00
|
|
|
}
|
|
|
|
|
2016-09-28 01:23:50 +00:00
|
|
|
static size_t zeroSequenceLength(const std::array<uint16_t, 8>& address, size_t begin)
|
2016-09-01 00:23:47 +00:00
|
|
|
{
|
|
|
|
size_t end = begin;
|
|
|
|
for (; end < 8; end++) {
|
|
|
|
if (address[end])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return end - begin;
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<size_t> findLongestZeroSequence(const std::array<uint16_t, 8>& address)
|
2016-09-01 00:23:47 +00:00
|
|
|
{
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<size_t> longest;
|
2016-09-01 00:23:47 +00:00
|
|
|
size_t longestLength = 0;
|
|
|
|
for (size_t i = 0; i < 8; i++) {
|
|
|
|
size_t length = zeroSequenceLength(address, i);
|
|
|
|
if (length) {
|
|
|
|
if (length > 1 && (!longest || longestLength < length)) {
|
|
|
|
longest = i;
|
|
|
|
longestLength = length;
|
|
|
|
}
|
|
|
|
i += length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return longest;
|
|
|
|
}
|
2016-09-23 23:40:46 +00:00
|
|
|
|
|
|
|
void URLParser::serializeIPv6Piece(uint16_t piece)
|
2016-09-01 00:23:47 +00:00
|
|
|
{
|
|
|
|
bool printed = false;
|
|
|
|
if (auto nibble0 = piece >> 12) {
|
2016-09-23 23:40:46 +00:00
|
|
|
appendToASCIIBuffer(lowerNibbleToLowercaseASCIIHexDigit(nibble0));
|
2016-09-01 00:23:47 +00:00
|
|
|
printed = true;
|
|
|
|
}
|
|
|
|
auto nibble1 = piece >> 8 & 0xF;
|
|
|
|
if (printed || nibble1) {
|
2016-09-23 23:40:46 +00:00
|
|
|
appendToASCIIBuffer(lowerNibbleToLowercaseASCIIHexDigit(nibble1));
|
2016-09-01 00:23:47 +00:00
|
|
|
printed = true;
|
|
|
|
}
|
|
|
|
auto nibble2 = piece >> 4 & 0xF;
|
|
|
|
if (printed || nibble2)
|
2016-09-23 23:40:46 +00:00
|
|
|
appendToASCIIBuffer(lowerNibbleToLowercaseASCIIHexDigit(nibble2));
|
|
|
|
appendToASCIIBuffer(lowerNibbleToLowercaseASCIIHexDigit(piece & 0xF));
|
2016-09-01 00:23:47 +00:00
|
|
|
}
|
|
|
|
|
2016-09-23 23:40:46 +00:00
|
|
|
void URLParser::serializeIPv6(URLParser::IPv6Address address)
|
2016-09-01 00:23:47 +00:00
|
|
|
{
|
2016-09-23 23:40:46 +00:00
|
|
|
appendToASCIIBuffer('[');
|
2016-09-01 00:23:47 +00:00
|
|
|
auto compressPointer = findLongestZeroSequence(address);
|
|
|
|
for (size_t piece = 0; piece < 8; piece++) {
|
|
|
|
if (compressPointer && compressPointer.value() == piece) {
|
|
|
|
ASSERT(!address[piece]);
|
|
|
|
if (piece)
|
2016-09-23 23:40:46 +00:00
|
|
|
appendToASCIIBuffer(':');
|
2016-09-01 00:23:47 +00:00
|
|
|
else
|
2016-09-23 23:40:46 +00:00
|
|
|
appendToASCIIBuffer("::", 2);
|
2016-09-08 17:19:25 +00:00
|
|
|
while (piece < 8 && !address[piece])
|
2016-09-01 00:23:47 +00:00
|
|
|
piece++;
|
|
|
|
if (piece == 8)
|
|
|
|
break;
|
|
|
|
}
|
2016-09-23 23:40:46 +00:00
|
|
|
serializeIPv6Piece(address[piece]);
|
2016-09-01 00:23:47 +00:00
|
|
|
if (piece < 7)
|
2016-09-23 23:40:46 +00:00
|
|
|
appendToASCIIBuffer(':');
|
2016-09-01 00:23:47 +00:00
|
|
|
}
|
2016-09-23 23:40:46 +00:00
|
|
|
appendToASCIIBuffer(']');
|
2016-09-01 00:23:47 +00:00
|
|
|
}
|
|
|
|
|
2017-02-14 07:43:28 +00:00
|
|
|
enum class URLParser::IPv4PieceParsingError {
|
|
|
|
Failure,
|
|
|
|
Overflow,
|
|
|
|
};
|
|
|
|
|
2016-09-15 18:12:09 +00:00
|
|
|
template<typename CharacterType>
|
2017-02-14 07:43:28 +00:00
|
|
|
Expected<uint32_t, URLParser::IPv4PieceParsingError> URLParser::parseIPv4Piece(CodePointIterator<CharacterType>& iterator, bool& didSeeSyntaxViolation)
|
2016-08-22 05:42:12 +00:00
|
|
|
{
|
|
|
|
enum class State : uint8_t {
|
|
|
|
UnknownBase,
|
|
|
|
Decimal,
|
|
|
|
OctalOrHex,
|
|
|
|
Octal,
|
|
|
|
Hex,
|
|
|
|
};
|
|
|
|
State state = State::UnknownBase;
|
2021-06-02 15:42:27 +00:00
|
|
|
CheckedUint32 value = 0;
|
2016-09-28 21:53:53 +00:00
|
|
|
if (!iterator.atEnd() && *iterator == '.')
|
2017-02-14 07:43:28 +00:00
|
|
|
return makeUnexpected(IPv4PieceParsingError::Failure);
|
2016-09-15 18:12:09 +00:00
|
|
|
while (!iterator.atEnd()) {
|
2016-10-03 22:55:46 +00:00
|
|
|
if (isTabOrNewline(*iterator)) {
|
|
|
|
didSeeSyntaxViolation = true;
|
|
|
|
++iterator;
|
|
|
|
continue;
|
|
|
|
}
|
2016-08-22 05:42:12 +00:00
|
|
|
if (*iterator == '.') {
|
2016-09-28 21:53:53 +00:00
|
|
|
ASSERT(!value.hasOverflowed());
|
2021-06-02 05:21:13 +00:00
|
|
|
return value.value();
|
2016-08-22 05:42:12 +00:00
|
|
|
}
|
|
|
|
switch (state) {
|
|
|
|
case State::UnknownBase:
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (UNLIKELY(*iterator == '0')) {
|
2016-08-22 05:42:12 +00:00
|
|
|
++iterator;
|
|
|
|
state = State::OctalOrHex;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
state = State::Decimal;
|
|
|
|
break;
|
|
|
|
case State::OctalOrHex:
|
2016-09-28 21:53:53 +00:00
|
|
|
didSeeSyntaxViolation = true;
|
2016-08-22 05:42:12 +00:00
|
|
|
if (*iterator == 'x' || *iterator == 'X') {
|
|
|
|
++iterator;
|
|
|
|
state = State::Hex;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
state = State::Octal;
|
|
|
|
break;
|
|
|
|
case State::Decimal:
|
Use ASCIICType more, and improve it a little bit
https://bugs.webkit.org/show_bug.cgi?id=165360
Reviewed by Sam Weinig.
Source/JavaScriptCore:
* inspector/InspectorValues.cpp:
(Inspector::readHexDigits): Use isASCIIHexDigit.
(Inspector::hextoInt): Deleted.
(decodeString): Use toASCIIHexValue.
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::parseDigit): Use isASCIIDigit, isASCIIUpper, and isASCIILower.
* runtime/StringPrototype.cpp:
(JSC::substituteBackreferencesSlow): Use isASCIIDigit.
Source/WebCore:
* css/CSSGrammar.y.in: Use isASCIIDigit.
* css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseFontFaceUnicodeRange): Use isASCIIHexDigit and
toASCIIHexValue.
(WebCore::isEqualToCSSIdentifier): Use isASCIILower.
* html/FormController.cpp:
(WebCore::isNotFormControlTypeCharacter): Use isASCIILower.
* html/parser/CSSPreloadScanner.cpp:
(WebCore::CSSPreloadScanner::tokenize): Use isASCIIAlpha.
* platform/Decimal.cpp:
(WebCore::Decimal::fromString): Use isASCIIDigit.
* platform/FileSystem.cpp:
(WebCore::decodeFromFilename): Use isASCIIHexDigit and toASCIIHexValue.
* platform/URL.cpp:
(WebCore::isLetterMatchIgnoringCase): Deleted.
(WebCore::isSchemeCharacterMatchIgnoringCase): Deleted.
(WebCore::assertProtocolIsGood): Use isASCIIUpper.
(WebCore::URL::protocolIs): Use isASCIIAlphaCaselessEqual.
(WebCore::URL::parse): Ditto.
(WebCore::protocolIs): Ditto.
(WebCore::protocolIsInHTTPFamily): Ditto.
* platform/URLParser.cpp:
(WeCore::URLParser::parseIPv4Piece): Use isASCIIDigit.
* platform/mac/WebCoreNSURLExtras.mm:
(WebCore::isRussianDomainNameCharacter): Use isASCIIDigit.
(WebCore::allCharactersAllowedByTLDRules): Ditto.
(WebCore::dataWithUserTypedString): Use upperNibbleToASCIIHexDigit and
lowerNibbleToASCIIHexDigit.
(WebCore::dataForURLComponentType): Ditto.
(WebCore::createStringWithEscapedUnsafeCharacters): Ditto.
(WebCore::userVisibleString): Use isASCIIHexDigit, toASCIIHexValue,
upperNibbleToASCIIHexDigit, and lowerNibbleToASCIIHexDigit.
(WebCore::isUserVisibleURL): Use isASCIIHexDigit and toASCIIHexValue.
* platform/network/FormDataBuilder.cpp:
(WebCore::FormDataBuilder::encodeStringAsFormData): Use isASCIIAlphanumeric.
* rendering/mathml/RenderMathMLToken.cpp:
(WebCore::mathVariant): Use isASCIIUpper, isASCIILower, and isASCIIDigit.
* svg/SVGParserUtilities.cpp:
(WebCore::genericParseNumber): Use isASCIIDigit.
* svg/SVGPathStringSource.cpp:
(WebCore::nextCommandHelper): Ditto.
* xml/XPathParser.cpp:
(WebCore::XPath::Parser::lexNumber): Ditto.
(WebCore::XPath::Parser::nextTokenInternal): Ditto.
Source/WebKit2:
* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::capitalizeRFC822HeaderFieldName): Removed unneeded checks to simplify code.
Source/WTF:
* wtf/ASCIICType.h: Added declarations of all the functions to the top of the file,
so we have a list of what's available, not just a mix of that and the implementation.
* wtf/HexNumber.h:
(WTF::Internal::hexDigitsForMode): Moved lowerHexDigits and upperHexDigits
inside this function.
(WTF::appendByteAsHex): Use auto.
(WTF::placeByteAsHexCompressIfPossible): Ditto.
(WTF::placeByteAsHex): Ditto.
(WTF::appendUnsignedAsHex): Ditto.
(WTF::appendUnsigned64AsHex): Ditto.
(WTF::appendUnsignedAsHexFixedSize): Ditto.
(WTF::isHexDigit): Deleted.
(WTF::uncheckedHexDigit): Deleted.
(WTF::hexDigitValue): Deleted.
(WTF::uncheckedHexDigitValue): Deleted.
* wtf/SixCharacterHash.cpp:
(WTF::sixCharacterHashStringToInteger): Use isASCIIUpper, isASCIILower, and
isASCIIDigit. Also added some FIXMEs; for some reason this function uses
RELEASE_ASSERT to abort if the passed-in string is not six characters long,
and it's not clear to me why this is so critical to assert.
(WTF::integerToSixCharacterHashString): Moved the table inside this function,
obviating the need for a macro named TABLE.
* wtf/dtoa/bignum.cc:
(WTF::double_conversion::HexCharValue): Deleted.
(WTF::double_conversion::Bignum::AssignHexString): Use toASCIIHexValue.
* wtf/dtoa/double-conversion.cc:
(WTF::double_conversion::StringToDoubleConverter::StringToDouble): Use isASCIIDigit.
* wtf/text/StringBuilder.cpp:
(WTF::appendQuotedJSONStringInternal): Use upperNibbleToASCIIHexDigit and
lowerNibbleToASCIIHexDigit.
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::convertToUppercaseWithoutLocale): Use toASCIIUpper.
Removed the workaround for a bug that was fixed in Visual Studio 2013.
Canonical link: https://commits.webkit.org/183066@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-06 17:18:20 +00:00
|
|
|
if (!isASCIIDigit(*iterator))
|
2017-02-14 07:43:28 +00:00
|
|
|
return makeUnexpected(IPv4PieceParsingError::Failure);
|
2016-08-22 05:42:12 +00:00
|
|
|
value *= 10;
|
|
|
|
value += *iterator - '0';
|
2016-09-28 21:53:53 +00:00
|
|
|
if (UNLIKELY(value.hasOverflowed()))
|
2017-02-14 07:43:28 +00:00
|
|
|
return makeUnexpected(IPv4PieceParsingError::Overflow);
|
2016-08-22 05:42:12 +00:00
|
|
|
++iterator;
|
|
|
|
break;
|
|
|
|
case State::Octal:
|
2016-09-28 21:53:53 +00:00
|
|
|
ASSERT(didSeeSyntaxViolation);
|
2016-08-22 05:42:12 +00:00
|
|
|
if (*iterator < '0' || *iterator > '7')
|
2017-02-14 07:43:28 +00:00
|
|
|
return makeUnexpected(IPv4PieceParsingError::Failure);
|
2016-08-22 05:42:12 +00:00
|
|
|
value *= 8;
|
|
|
|
value += *iterator - '0';
|
2016-09-28 21:53:53 +00:00
|
|
|
if (UNLIKELY(value.hasOverflowed()))
|
2017-02-14 07:43:28 +00:00
|
|
|
return makeUnexpected(IPv4PieceParsingError::Overflow);
|
2016-08-22 05:42:12 +00:00
|
|
|
++iterator;
|
|
|
|
break;
|
|
|
|
case State::Hex:
|
2016-09-28 21:53:53 +00:00
|
|
|
ASSERT(didSeeSyntaxViolation);
|
2016-08-22 05:42:12 +00:00
|
|
|
if (!isASCIIHexDigit(*iterator))
|
2017-02-14 07:43:28 +00:00
|
|
|
return makeUnexpected(IPv4PieceParsingError::Failure);
|
2016-08-22 05:42:12 +00:00
|
|
|
value *= 16;
|
|
|
|
value += toASCIIHexValue(*iterator);
|
2016-09-28 21:53:53 +00:00
|
|
|
if (UNLIKELY(value.hasOverflowed()))
|
2017-02-14 07:43:28 +00:00
|
|
|
return makeUnexpected(IPv4PieceParsingError::Overflow);
|
2016-08-22 05:42:12 +00:00
|
|
|
++iterator;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-09-28 21:53:53 +00:00
|
|
|
ASSERT(!value.hasOverflowed());
|
2021-06-02 05:21:13 +00:00
|
|
|
return value.value();
|
2016-08-22 05:42:12 +00:00
|
|
|
}
|
|
|
|
|
2016-09-28 01:23:50 +00:00
|
|
|
ALWAYS_INLINE static uint64_t pow256(size_t exponent)
|
2016-08-22 05:42:12 +00:00
|
|
|
{
|
|
|
|
RELEASE_ASSERT(exponent <= 4);
|
|
|
|
uint64_t values[5] = {1, 256, 256 * 256, 256 * 256 * 256, 256ull * 256 * 256 * 256 };
|
|
|
|
return values[exponent];
|
|
|
|
}
|
|
|
|
|
2017-02-14 07:43:28 +00:00
|
|
|
enum class URLParser::IPv4ParsingError {
|
|
|
|
Failure,
|
|
|
|
NotIPv4,
|
|
|
|
};
|
|
|
|
|
2017-02-03 06:30:30 +00:00
|
|
|
template<typename CharacterTypeForSyntaxViolation, typename CharacterType>
|
2017-02-14 07:43:28 +00:00
|
|
|
Expected<URLParser::IPv4Address, URLParser::IPv4ParsingError> URLParser::parseIPv4Host(const CodePointIterator<CharacterTypeForSyntaxViolation>& iteratorForSyntaxViolationPosition, CodePointIterator<CharacterType> iterator)
|
2016-08-22 05:42:12 +00:00
|
|
|
{
|
2017-02-14 07:43:28 +00:00
|
|
|
Vector<Expected<uint32_t, URLParser::IPv4PieceParsingError>, 4> items;
|
2016-09-29 22:02:04 +00:00
|
|
|
bool didSeeSyntaxViolation = false;
|
2017-02-14 07:43:28 +00:00
|
|
|
if (!iterator.atEnd() && *iterator == '.')
|
|
|
|
return makeUnexpected(IPv4ParsingError::NotIPv4);
|
2016-09-15 18:12:09 +00:00
|
|
|
while (!iterator.atEnd()) {
|
2016-10-03 22:55:46 +00:00
|
|
|
if (isTabOrNewline(*iterator)) {
|
|
|
|
didSeeSyntaxViolation = true;
|
|
|
|
++iterator;
|
|
|
|
continue;
|
|
|
|
}
|
2016-08-22 05:42:12 +00:00
|
|
|
if (items.size() >= 4)
|
2017-02-14 07:43:28 +00:00
|
|
|
return makeUnexpected(IPv4ParsingError::NotIPv4);
|
|
|
|
items.append(parseIPv4Piece(iterator, didSeeSyntaxViolation));
|
|
|
|
if (!iterator.atEnd() && *iterator == '.') {
|
|
|
|
++iterator;
|
|
|
|
if (iterator.atEnd())
|
2019-07-09 19:15:04 +00:00
|
|
|
didSeeSyntaxViolation = true;
|
2017-02-14 07:43:28 +00:00
|
|
|
else if (*iterator == '.')
|
|
|
|
return makeUnexpected(IPv4ParsingError::NotIPv4);
|
2016-09-29 20:21:54 +00:00
|
|
|
}
|
2016-08-22 05:42:12 +00:00
|
|
|
}
|
2016-09-29 20:21:54 +00:00
|
|
|
if (!iterator.atEnd() || !items.size() || items.size() > 4)
|
2017-02-14 07:43:28 +00:00
|
|
|
return makeUnexpected(IPv4ParsingError::NotIPv4);
|
|
|
|
for (const auto& item : items) {
|
2017-12-04 23:34:57 +00:00
|
|
|
if (!item.has_value() && item.error() == IPv4PieceParsingError::Failure)
|
2017-02-14 07:43:28 +00:00
|
|
|
return makeUnexpected(IPv4ParsingError::NotIPv4);
|
|
|
|
}
|
|
|
|
for (const auto& item : items) {
|
2017-12-04 23:34:57 +00:00
|
|
|
if (!item.has_value() && item.error() == IPv4PieceParsingError::Overflow)
|
2017-02-14 07:43:28 +00:00
|
|
|
return makeUnexpected(IPv4ParsingError::Failure);
|
|
|
|
}
|
2016-09-30 18:50:49 +00:00
|
|
|
if (items.size() > 1) {
|
|
|
|
for (size_t i = 0; i < items.size() - 1; i++) {
|
2017-02-14 07:43:28 +00:00
|
|
|
if (items[i].value() > 255)
|
|
|
|
return makeUnexpected(IPv4ParsingError::Failure);
|
2016-09-19 23:05:11 +00:00
|
|
|
}
|
2016-08-22 05:42:12 +00:00
|
|
|
}
|
2017-02-14 07:43:28 +00:00
|
|
|
if (items[items.size() - 1].value() >= pow256(5 - items.size()))
|
|
|
|
return makeUnexpected(IPv4ParsingError::Failure);
|
2016-09-29 22:02:04 +00:00
|
|
|
|
|
|
|
if (didSeeSyntaxViolation)
|
2017-02-03 06:30:30 +00:00
|
|
|
syntaxViolation(iteratorForSyntaxViolationPosition);
|
2017-02-14 07:43:28 +00:00
|
|
|
for (const auto& item : items) {
|
|
|
|
if (item.value() > 255)
|
2017-02-03 06:30:30 +00:00
|
|
|
syntaxViolation(iteratorForSyntaxViolationPosition);
|
2016-08-22 05:42:12 +00:00
|
|
|
}
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
|
|
|
|
if (UNLIKELY(items.size() != 4))
|
2017-02-03 06:30:30 +00:00
|
|
|
syntaxViolation(iteratorForSyntaxViolationPosition);
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
|
2017-02-14 07:43:28 +00:00
|
|
|
IPv4Address ipv4 = items.takeLast().value();
|
2016-08-22 05:42:12 +00:00
|
|
|
for (size_t counter = 0; counter < items.size(); ++counter)
|
2017-02-14 07:43:28 +00:00
|
|
|
ipv4 += items[counter].value() * pow256(3 - counter);
|
2016-08-22 05:42:12 +00:00
|
|
|
return ipv4;
|
|
|
|
}
|
2016-10-06 02:35:12 +00:00
|
|
|
|
|
|
|
template<typename CharacterType>
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<uint32_t> URLParser::parseIPv4PieceInsideIPv6(CodePointIterator<CharacterType>& iterator)
|
2016-10-06 02:35:12 +00:00
|
|
|
{
|
|
|
|
if (iterator.atEnd())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-10-06 02:35:12 +00:00
|
|
|
uint32_t piece = 0;
|
|
|
|
bool leadingZeros = false;
|
|
|
|
size_t digitCount = 0;
|
|
|
|
while (!iterator.atEnd()) {
|
|
|
|
if (!isASCIIDigit(*iterator))
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-10-06 02:35:12 +00:00
|
|
|
++digitCount;
|
|
|
|
if (!piece && *iterator == '0') {
|
|
|
|
if (leadingZeros)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-10-06 02:35:12 +00:00
|
|
|
leadingZeros = true;
|
|
|
|
}
|
|
|
|
if (!piece && *iterator == '0')
|
|
|
|
leadingZeros = true;
|
|
|
|
piece = piece * 10 + *iterator - '0';
|
|
|
|
if (piece > 255)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-10-06 02:35:12 +00:00
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(iterator);
|
|
|
|
if (iterator.atEnd())
|
|
|
|
break;
|
|
|
|
if (*iterator == '.')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (piece && leadingZeros)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-10-06 02:35:12 +00:00
|
|
|
return piece;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename CharacterType>
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<URLParser::IPv4Address> URLParser::parseIPv4AddressInsideIPv6(CodePointIterator<CharacterType> iterator)
|
2016-10-06 02:35:12 +00:00
|
|
|
{
|
|
|
|
IPv4Address address = 0;
|
|
|
|
for (size_t i = 0; i < 4; ++i) {
|
2021-05-30 16:11:40 +00:00
|
|
|
if (std::optional<uint32_t> piece = parseIPv4PieceInsideIPv6(iterator))
|
2016-10-06 02:35:12 +00:00
|
|
|
address = (address << 8) + piece.value();
|
|
|
|
else
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-10-06 02:35:12 +00:00
|
|
|
if (i < 3) {
|
|
|
|
if (iterator.atEnd())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-10-06 02:35:12 +00:00
|
|
|
if (*iterator != '.')
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-10-06 02:35:12 +00:00
|
|
|
advance<CharacterType, ReportSyntaxViolation::No>(iterator);
|
|
|
|
} else if (!iterator.atEnd())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-10-06 02:35:12 +00:00
|
|
|
}
|
|
|
|
ASSERT(iterator.atEnd());
|
|
|
|
return address;
|
|
|
|
}
|
|
|
|
|
2016-09-15 18:12:09 +00:00
|
|
|
template<typename CharacterType>
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<URLParser::IPv6Address> URLParser::parseIPv6Host(CodePointIterator<CharacterType> c)
|
2016-08-22 05:42:12 +00:00
|
|
|
{
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
ASSERT(*c == '[');
|
2017-02-03 06:30:30 +00:00
|
|
|
const auto hostBegin = c;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(c, hostBegin);
|
2016-09-15 18:12:09 +00:00
|
|
|
if (c.atEnd())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-09-01 00:23:47 +00:00
|
|
|
|
2016-09-23 23:40:46 +00:00
|
|
|
IPv6Address address = {{0, 0, 0, 0, 0, 0, 0, 0}};
|
2016-09-01 00:23:47 +00:00
|
|
|
size_t piecePointer = 0;
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<size_t> compressPointer;
|
2019-05-31 20:56:40 +00:00
|
|
|
bool previousValueWasZero = false;
|
|
|
|
bool immediatelyAfterCompress = false;
|
2016-09-01 00:23:47 +00:00
|
|
|
|
|
|
|
if (*c == ':') {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(c, hostBegin);
|
2016-09-15 18:12:09 +00:00
|
|
|
if (c.atEnd())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-09-01 00:23:47 +00:00
|
|
|
if (*c != ':')
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(c, hostBegin);
|
2016-09-01 00:23:47 +00:00
|
|
|
++piecePointer;
|
|
|
|
compressPointer = piecePointer;
|
2019-05-31 20:56:40 +00:00
|
|
|
immediatelyAfterCompress = true;
|
2016-09-01 00:23:47 +00:00
|
|
|
}
|
|
|
|
|
2016-09-15 18:12:09 +00:00
|
|
|
while (!c.atEnd()) {
|
2016-09-01 00:23:47 +00:00
|
|
|
if (piecePointer == 8)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-09-01 00:23:47 +00:00
|
|
|
if (*c == ':') {
|
|
|
|
if (compressPointer)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(c, hostBegin);
|
2016-09-01 00:23:47 +00:00
|
|
|
++piecePointer;
|
|
|
|
compressPointer = piecePointer;
|
2019-05-31 20:56:40 +00:00
|
|
|
immediatelyAfterCompress = true;
|
|
|
|
if (previousValueWasZero)
|
|
|
|
syntaxViolation(hostBegin);
|
2016-09-01 00:23:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-10-06 02:35:12 +00:00
|
|
|
if (piecePointer == 6 || (compressPointer && piecePointer < 6)) {
|
2021-05-30 16:11:40 +00:00
|
|
|
if (std::optional<IPv4Address> ipv4Address = parseIPv4AddressInsideIPv6(c)) {
|
2016-10-06 02:35:12 +00:00
|
|
|
if (compressPointer && piecePointer == 5)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-10-06 02:35:12 +00:00
|
|
|
syntaxViolation(hostBegin);
|
|
|
|
address[piecePointer++] = ipv4Address.value() >> 16;
|
|
|
|
address[piecePointer++] = ipv4Address.value() & 0xFFFF;
|
|
|
|
c = { };
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-09-01 00:23:47 +00:00
|
|
|
uint16_t value = 0;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
size_t length = 0;
|
2016-10-05 18:27:53 +00:00
|
|
|
bool leadingZeros = false;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
for (; length < 4; length++) {
|
2016-09-15 18:12:09 +00:00
|
|
|
if (c.atEnd())
|
2016-09-01 00:23:47 +00:00
|
|
|
break;
|
|
|
|
if (!isASCIIHexDigit(*c))
|
|
|
|
break;
|
2016-09-28 21:12:04 +00:00
|
|
|
if (isASCIIUpper(*c))
|
|
|
|
syntaxViolation(hostBegin);
|
2016-10-05 18:27:53 +00:00
|
|
|
if (*c == '0' && !length)
|
|
|
|
leadingZeros = true;
|
2016-09-01 00:23:47 +00:00
|
|
|
value = value * 0x10 + toASCIIHexValue(*c);
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(c, hostBegin);
|
2016-09-01 00:23:47 +00:00
|
|
|
}
|
2016-10-05 18:27:53 +00:00
|
|
|
|
2019-05-31 20:56:40 +00:00
|
|
|
previousValueWasZero = !value;
|
|
|
|
if (UNLIKELY((value && leadingZeros) || (previousValueWasZero && (length > 1 || immediatelyAfterCompress))))
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(hostBegin);
|
|
|
|
|
2016-09-01 00:23:47 +00:00
|
|
|
address[piecePointer++] = value;
|
2016-09-15 18:12:09 +00:00
|
|
|
if (c.atEnd())
|
2016-09-01 00:23:47 +00:00
|
|
|
break;
|
2016-09-29 20:18:16 +00:00
|
|
|
if (piecePointer == 8 || *c != ':')
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(c, hostBegin);
|
2019-07-09 19:12:42 +00:00
|
|
|
if (c.atEnd())
|
|
|
|
syntaxViolation(hostBegin);
|
2019-05-31 20:56:40 +00:00
|
|
|
|
|
|
|
immediatelyAfterCompress = false;
|
2016-09-01 00:23:47 +00:00
|
|
|
}
|
|
|
|
|
2016-10-06 02:35:12 +00:00
|
|
|
if (!c.atEnd())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-10-06 02:35:12 +00:00
|
|
|
|
2016-09-01 00:23:47 +00:00
|
|
|
if (compressPointer) {
|
|
|
|
size_t swaps = piecePointer - compressPointer.value();
|
|
|
|
piecePointer = 7;
|
|
|
|
while (swaps)
|
|
|
|
std::swap(address[piecePointer--], address[compressPointer.value() + swaps-- - 1]);
|
|
|
|
} else if (piecePointer != 8)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<size_t> possibleCompressPointer = findLongestZeroSequence(address);
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (possibleCompressPointer)
|
|
|
|
possibleCompressPointer.value()++;
|
|
|
|
if (UNLIKELY(compressPointer != possibleCompressPointer))
|
|
|
|
syntaxViolation(hostBegin);
|
|
|
|
|
2016-09-01 00:23:47 +00:00
|
|
|
return address;
|
2016-08-22 05:42:12 +00:00
|
|
|
}
|
|
|
|
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
template<typename CharacterType>
|
2018-04-30 21:17:59 +00:00
|
|
|
URLParser::LCharBuffer URLParser::percentDecode(const LChar* input, size_t length, const CodePointIterator<CharacterType>& iteratorForSyntaxViolationPosition)
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
{
|
2018-04-30 21:17:59 +00:00
|
|
|
LCharBuffer output;
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
output.reserveInitialCapacity(length);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < length; ++i) {
|
|
|
|
uint8_t byte = input[i];
|
|
|
|
if (byte != '%')
|
|
|
|
output.uncheckedAppend(byte);
|
|
|
|
else if (length > 2 && i < length - 2) {
|
|
|
|
if (isASCIIHexDigit(input[i + 1]) && isASCIIHexDigit(input[i + 2])) {
|
|
|
|
syntaxViolation(iteratorForSyntaxViolationPosition);
|
|
|
|
output.uncheckedAppend(toASCIIHexValue(input[i + 1], input[i + 2]));
|
|
|
|
i += 2;
|
|
|
|
} else
|
|
|
|
output.uncheckedAppend(byte);
|
|
|
|
} else
|
|
|
|
output.uncheckedAppend(byte);
|
|
|
|
}
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2018-04-30 21:17:59 +00:00
|
|
|
URLParser::LCharBuffer URLParser::percentDecode(const LChar* input, size_t length)
|
2016-09-06 18:16:07 +00:00
|
|
|
{
|
2018-04-30 21:17:59 +00:00
|
|
|
LCharBuffer output;
|
2016-09-20 21:50:30 +00:00
|
|
|
output.reserveInitialCapacity(length);
|
2016-09-06 18:16:07 +00:00
|
|
|
|
|
|
|
for (size_t i = 0; i < length; ++i) {
|
2016-09-14 01:34:27 +00:00
|
|
|
uint8_t byte = input[i];
|
2016-09-06 18:16:07 +00:00
|
|
|
if (byte != '%')
|
2016-09-20 21:50:30 +00:00
|
|
|
output.uncheckedAppend(byte);
|
2016-10-13 02:38:13 +00:00
|
|
|
else if (length > 2 && i < length - 2) {
|
2016-09-14 01:34:27 +00:00
|
|
|
if (isASCIIHexDigit(input[i + 1]) && isASCIIHexDigit(input[i + 2])) {
|
2016-09-20 21:50:30 +00:00
|
|
|
output.uncheckedAppend(toASCIIHexValue(input[i + 1], input[i + 2]));
|
2016-09-06 18:16:07 +00:00
|
|
|
i += 2;
|
|
|
|
} else
|
2016-09-20 21:50:30 +00:00
|
|
|
output.uncheckedAppend(byte);
|
2016-09-06 18:16:07 +00:00
|
|
|
} else
|
2016-09-20 21:50:30 +00:00
|
|
|
output.uncheckedAppend(byte);
|
2016-09-06 18:16:07 +00:00
|
|
|
}
|
2016-09-20 21:50:30 +00:00
|
|
|
return output;
|
2016-09-06 18:16:07 +00:00
|
|
|
}
|
|
|
|
|
Non-special URLs are not idempotent
https://bugs.webkit.org/show_bug.cgi?id=215762
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/url-constructor-expected.txt:
* web-platform-tests/url/url-setters-expected.txt:
Source/WTF:
https://github.com/whatwg/url/pull/505 added an interesting edge case to the URL serialization:
"If url’s host is null, url’s path’s size is greater than 1, and url’s path[0] is the empty string, then append U+002F (/) followed by U+002E (.) to output."
The problem was that URLs like "a:/a/..//a" would be parsed into "a://a" with a pathname of "//a" and an empty host. If "a://a" was then reparsed, it would again have an href of "a://a"
but its host would be "a" and it would have an empty path. There is consensus that URL parsing should be idempotent, so we need to do something different here.
According to https://github.com/whatwg/url/issues/415#issuecomment-419197290 this follows what Edge did (and then subsequently abandoned when they switched to Chromium)
to make URL parsing idempotent by adding "/." before the path in the edge case of a URL with a non-special scheme (not http, https, wss, etc.) and a null host and a non-empty path that
has an empty first segment. All the members of the URL remain unchanged except the full serialization (href). This is not important in practice, but important in theory.
Our URL parser tries very hard to use the exact same WTF::String object given as input if it can. However, this step is better implemented as a post-processing step that will almost never happen
because otherwise we would have to parse the entire path twice to find out if we need to add "./" or if the "./" that may have already been there needs to stay. This is illustrated with the test URL
"t:/.//p/../../../..//x" which does need the "./".
In the common case, this adds one well-predicted branch to URL parsing, so I expect performance to be unaffected. Since this is such a rare edge case of URLs, I expect no compatibility problems.
* wtf/URL.cpp:
(WTF::URL::pathStart const):
* wtf/URL.h:
(WTF::URL::pathStart const): Deleted.
* wtf/URLParser.cpp:
(WTF::URLParser::copyURLPartsUntil):
(WTF::URLParser::URLParser):
(WTF::URLParser::needsNonSpecialDotSlash const):
(WTF::URLParser::addNonSpecialDotSlash):
* wtf/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WTF/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/229956@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267837 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-01 17:05:41 +00:00
|
|
|
bool URLParser::needsNonSpecialDotSlash() const
|
|
|
|
{
|
|
|
|
auto pathStart = m_url.m_hostEnd + m_url.m_portLength;
|
|
|
|
return !m_urlIsSpecial
|
2020-10-12 17:39:52 +00:00
|
|
|
&& pathStart == m_url.m_schemeEnd + 1U
|
Non-special URLs are not idempotent
https://bugs.webkit.org/show_bug.cgi?id=215762
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/url-constructor-expected.txt:
* web-platform-tests/url/url-setters-expected.txt:
Source/WTF:
https://github.com/whatwg/url/pull/505 added an interesting edge case to the URL serialization:
"If url’s host is null, url’s path’s size is greater than 1, and url’s path[0] is the empty string, then append U+002F (/) followed by U+002E (.) to output."
The problem was that URLs like "a:/a/..//a" would be parsed into "a://a" with a pathname of "//a" and an empty host. If "a://a" was then reparsed, it would again have an href of "a://a"
but its host would be "a" and it would have an empty path. There is consensus that URL parsing should be idempotent, so we need to do something different here.
According to https://github.com/whatwg/url/issues/415#issuecomment-419197290 this follows what Edge did (and then subsequently abandoned when they switched to Chromium)
to make URL parsing idempotent by adding "/." before the path in the edge case of a URL with a non-special scheme (not http, https, wss, etc.) and a null host and a non-empty path that
has an empty first segment. All the members of the URL remain unchanged except the full serialization (href). This is not important in practice, but important in theory.
Our URL parser tries very hard to use the exact same WTF::String object given as input if it can. However, this step is better implemented as a post-processing step that will almost never happen
because otherwise we would have to parse the entire path twice to find out if we need to add "./" or if the "./" that may have already been there needs to stay. This is illustrated with the test URL
"t:/.//p/../../../..//x" which does need the "./".
In the common case, this adds one well-predicted branch to URL parsing, so I expect performance to be unaffected. Since this is such a rare edge case of URLs, I expect no compatibility problems.
* wtf/URL.cpp:
(WTF::URL::pathStart const):
* wtf/URL.h:
(WTF::URL::pathStart const): Deleted.
* wtf/URLParser.cpp:
(WTF::URLParser::copyURLPartsUntil):
(WTF::URLParser::URLParser):
(WTF::URLParser::needsNonSpecialDotSlash const):
(WTF::URLParser::addNonSpecialDotSlash):
* wtf/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WTF/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/229956@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267837 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-01 17:05:41 +00:00
|
|
|
&& pathStart + 1 < m_url.m_string.length()
|
|
|
|
&& m_url.m_string[pathStart] == '/'
|
|
|
|
&& m_url.m_string[pathStart + 1] == '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
void URLParser::addNonSpecialDotSlash()
|
|
|
|
{
|
|
|
|
auto oldPathStart = m_url.m_hostEnd + m_url.m_portLength;
|
|
|
|
auto& oldString = m_url.m_string;
|
|
|
|
m_url.m_string = makeString(oldString.substring(0, oldPathStart + 1), "./", oldString.substring(oldPathStart + 1));
|
|
|
|
m_url.m_pathAfterLastSlash += 2;
|
|
|
|
m_url.m_pathEnd += 2;
|
|
|
|
m_url.m_queryEnd += 2;
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
template<typename CharacterType> std::optional<URLParser::LCharBuffer> URLParser::domainToASCII(StringImpl& domain, const CodePointIterator<CharacterType>& iteratorForSyntaxViolationPosition)
|
2016-09-06 18:16:07 +00:00
|
|
|
{
|
2018-04-30 21:17:59 +00:00
|
|
|
LCharBuffer ascii;
|
2021-06-15 16:59:15 +00:00
|
|
|
if (domain.isAllASCII() && !subdomainStartsWithXNDashDash(domain)) {
|
2016-09-08 17:23:30 +00:00
|
|
|
size_t length = domain.length();
|
2016-09-20 21:50:30 +00:00
|
|
|
if (domain.is8Bit()) {
|
|
|
|
const LChar* characters = domain.characters8();
|
|
|
|
ascii.reserveInitialCapacity(length);
|
2016-11-01 21:31:40 +00:00
|
|
|
for (size_t i = 0; i < length; ++i) {
|
|
|
|
if (UNLIKELY(isASCIIUpper(characters[i])))
|
|
|
|
syntaxViolation(iteratorForSyntaxViolationPosition);
|
|
|
|
ascii.uncheckedAppend(toASCIILower(characters[i]));
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
}
|
2016-09-20 21:50:30 +00:00
|
|
|
} else {
|
|
|
|
const UChar* characters = domain.characters16();
|
|
|
|
ascii.reserveInitialCapacity(length);
|
2016-11-01 21:31:40 +00:00
|
|
|
for (size_t i = 0; i < length; ++i) {
|
|
|
|
if (UNLIKELY(isASCIIUpper(characters[i])))
|
|
|
|
syntaxViolation(iteratorForSyntaxViolationPosition);
|
|
|
|
ascii.uncheckedAppend(toASCIILower(characters[i]));
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
}
|
2016-09-20 21:50:30 +00:00
|
|
|
}
|
|
|
|
return ascii;
|
2016-09-08 17:23:30 +00:00
|
|
|
}
|
2021-06-15 16:59:15 +00:00
|
|
|
|
|
|
|
UChar hostnameBuffer[hostnameBufferLength];
|
2016-09-08 17:23:30 +00:00
|
|
|
UErrorCode error = U_ZERO_ERROR;
|
Support IDN2008 with UTS #46 instead of IDN2003
https://bugs.webkit.org/show_bug.cgi?id=144194
Reviewed by Darin Adler.
Source/WebCore:
Use uidna_nameToASCII instead of the deprecated uidna_IDNToASCII.
It uses IDN2008 instead of IDN2003, and it uses UTF #46 when used with a UIDNA opened with uidna_openUTS46.
This follows https://url.spec.whatwg.org/#concept-domain-to-ascii except we do not use Transitional_Processing
to prevent homograph attacks on german domain names with "ß" and "ss" in them. These are now treated as separate domains.
Firefox also doesn't use Transitional_Processing. Chrome and the current specification use Transitional_processing,
but https://github.com/whatwg/url/issues/110 might change the spec.
In addition, http://unicode.org/reports/tr46/ says:
"implementations are encouraged to apply the Bidi and ContextJ validity criteria"
Bidi checks prevent domain names with bidirectional text, such as latin and hebrew characters in the same domain. Chrome and Firefox do this.
ContextJ checks prevent code points such as U+200D, which is a zero-width joiner which users would not see when looking at the domain name.
Firefox currently enables ContextJ checks and it is suggested by UTS #46, so we'll do it.
ContextO checks, which we do not use and neither does any other browser nor the spec, would fail if a domain contains code points such as U+30FB,
which looks somewhat like a dot. We can investigate enabling these checks later.
Covered by new API tests and rebased LayoutTests.
The new API tests verify that we do not use transitional processing, that we do apply the Bidi and ContextJ checks, but not ContextO checks.
* platform/URLParser.cpp:
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::internationalDomainNameTranscoder):
* platform/URLParser.h:
* platform/mac/WebCoreNSURLExtras.mm:
(WebCore::mapHostNameWithRange):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Add some tests from http://unicode.org/faq/idn.html verifying that we follow UTS46's deviations from IDN2008.
Add some tests based on https://tools.ietf.org/html/rfc5893 verifying that we check for bidirectional text.
Add a test based on https://tools.ietf.org/html/rfc5892 verifying that we do not do ContextO check.
Add a test for U+321D and U+321E which have particularly interesting punycode encodings. We match Firefox here now.
Also add a test from http://www.unicode.org/reports/tr46/#IDNAComparison verifying we are not using IDN2003.
We should consider importing all of http://www.unicode.org/Public/idna/9.0.0/IdnaTest.txt as URL domain tests.
LayoutTests:
* fast/encoding/idn-security.html:
Move some characters with changed IDN encodings to inside the check for old ICU.
* fast/url/idna2003-expected.txt:
* fast/url/idna2008-expected.txt:
Update expected results. We are now more compliant with IDN2008.
Canonical link: https://commits.webkit.org/182613@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208902 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-18 22:47:24 +00:00
|
|
|
UIDNAInfo processingDetails = UIDNA_INFO_INITIALIZER;
|
2021-06-15 16:59:15 +00:00
|
|
|
int32_t numCharactersConverted = uidna_nameToASCII(&internationalDomainNameTranscoder(), StringView(domain).upconvertedCharacters(), domain.length(), hostnameBuffer, hostnameBufferLength, &processingDetails, &error);
|
2016-09-08 17:23:30 +00:00
|
|
|
|
2021-06-15 16:59:15 +00:00
|
|
|
if (U_SUCCESS(error) && !(processingDetails.errors & ~allowedNameToASCIIErrors) && numCharactersConverted) {
|
PerformanceTests:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* JetStream2/wasm/HashSet.cpp:
* StitchMarker/wtf/Assertions.h:
* StitchMarker/wtf/DateMath.cpp:
(WTF::initializeDates):
* StitchMarker/wtf/HashTable.h:
* StitchMarker/wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
* StitchMarker/wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* StitchMarker/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* StitchMarker/wtf/ValueCheck.h:
* StitchMarker/wtf/Vector.h:
(WTF::minCapacity>::checkConsistency):
* StitchMarker/wtf/text/AtomicStringImpl.cpp:
* StitchMarker/wtf/text/AtomicStringImpl.h:
* StitchMarker/wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* StitchMarker/wtf/text/StringImpl.h:
* StitchMarker/wtf/text/SymbolImpl.h:
* StitchMarker/wtf/text/UniquedStringImpl.h:
Source/JavaScriptCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* API/tests/testapi.c:
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithLoad):
(JSC::ARM64Assembler::replaceWithAddressComputation):
* assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::LocalWriter::LocalWriter):
* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::Stack):
* assembler/ProbeStack.h:
* b3/B3FoldPathConstants.cpp:
* b3/B3LowerToAir.cpp:
* b3/B3MemoryValue.cpp:
(JSC::B3::MemoryValue::MemoryValue):
* b3/B3Opcode.cpp:
* b3/B3Type.h:
* b3/B3TypeMap.h:
* b3/B3Width.h:
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration):
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.h:
* b3/air/AirAllocateRegistersByGraphColoring.cpp:
* b3/air/AirArg.cpp:
* b3/air/AirArg.h:
* b3/air/AirCode.h:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/AccessCase.cpp:
* bytecode/AccessCase.h:
* bytecode/CallVariant.cpp:
(JSC::variantListWithVariant):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex):
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::dump const):
* bytecode/StructureStubInfo.cpp:
* bytecode/StructureStubInfo.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionCallResolveNode::emitBytecode):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
* debugger/Debugger.cpp:
(JSC::Debugger::removeBreakpoint):
* debugger/DebuggerEvalEnabler.h:
(JSC::DebuggerEvalEnabler::DebuggerEvalEnabler):
(JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions):
* dfg/DFGAbstractValue.cpp:
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::merge):
(JSC::DFG::AbstractValue::checkConsistency const):
(JSC::DFG::AbstractValue::assertIsRegistered const):
* dfg/DFGArithMode.h:
(JSC::DFG::doesOverflow):
* dfg/DFGBasicBlock.cpp:
(JSC::DFG::BasicBlock::BasicBlock):
* dfg/DFGBasicBlock.h:
(JSC::DFG::BasicBlock::didLink):
* dfg/DFGCFAPhase.cpp:
(JSC::DFG::CFAPhase::performBlockCFA):
* dfg/DFGCommon.h:
(JSC::DFG::validationEnabled):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGEdge.h:
(JSC::DFG::Edge::makeWord):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::assertClear):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::SlowPathGenerator::generate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
(JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse):
(JSC::DFG::SpeculativeJIT::emitAllocateButterfly):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
* dfg/DFGStructureAbstractValue.cpp:
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::assertIsRegistered const):
* dfg/DFGVarargsForwardingPhase.cpp:
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::callPreflight):
(JSC::FTL::DFG::LowerDFGToB3::callCheck):
(JSC::FTL::DFG::LowerDFGToB3::crash):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::assertNoUnswept):
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::validatePrevious):
* heap/HandleSet.cpp:
* heap/HandleSet.h:
* heap/Heap.cpp:
(JSC::Heap::updateAllocationLimits):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::assertValidCell const):
(JSC::MarkedBlock::assertMarksNotStale):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::beginMarking):
(JSC::MarkedSpace::endMarking):
(JSC::MarkedSpace::assertNoUnswept):
* heap/PreciseAllocation.cpp:
* heap/PreciseAllocation.h:
(JSC::PreciseAllocation::assertValidCell const):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
* heap/SlotVisitor.h:
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
(CppProtocolTypesImplementationGenerator):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* interpreter/FrameTracers.h:
(JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
* interpreter/Interpreter.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::prepareCallOperation):
* jit/BinarySwitch.cpp:
(JSC::BinarySwitch::BinarySwitch):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupStubArgs):
* jit/CallFrameShuffler.cpp:
(JSC::CallFrameShuffler::emitDeltaCheck):
(JSC::CallFrameShuffler::prepareAny):
* jit/JIT.cpp:
(JSC::JIT::assertStackPointerOffset):
(JSC::JIT::compileWithoutLinking):
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_loop_hint):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jit/ThunkGenerators.cpp:
(JSC::emitPointerValidation):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LLIntOfflineAsmConfig.h:
* parser/Lexer.cpp:
* parser/Lexer.h:
(JSC::isSafeBuiltinIdentifier):
(JSC::Lexer<T>::lexExpectIdentifier):
* runtime/ArgList.h:
(JSC::MarkedArgumentBuffer::setNeedsOverflowCheck):
(JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck):
* runtime/Butterfly.h:
(JSC::ContiguousData::ContiguousData):
(JSC::ContiguousData::Data::Data):
* runtime/HashMapImpl.h:
(JSC::HashMapImpl::checkConsistency const):
(JSC::HashMapImpl::assertBufferIsEmpty const):
* runtime/JSCellInlines.h:
(JSC::JSCell::methodTable const):
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
(JSC::JSFunction::assertTypeInfoFlagInvariants):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren):
(JSC::JSFinalObject::visitChildren):
* runtime/JSObjectInlines.h:
(JSC::JSObject::validatePutOwnDataProperty):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::assertVariableIsInThisObject):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lex):
* runtime/LiteralParser.h:
* runtime/Operations.h:
(JSC::scribbleFreeCells):
* runtime/OptionsList.h:
* runtime/VM.cpp:
(JSC::VM::computeCanUseJIT):
* runtime/VM.h:
(JSC::VM::canUseJIT):
* runtime/VarOffset.h:
(JSC::VarOffset::checkSanity const):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::checkConsistency const):
(JSC::WeakMapImpl::assertBufferIsEmpty const):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::validateInst):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::validationFail const):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::checkConsistency):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast):
* wasm/WasmSectionParser.h:
* wasm/WasmSections.h:
* wasm/WasmSignatureInlines.h:
(JSC::Wasm::SignatureInformation::get):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::enqueue):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::previousInstanceOffset const):
Source/WebCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTask::performTask):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::terminationRequested const):
* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h:
(WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation):
* Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp:
(WebCore::WHLSL::findHighZombies):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::matches):
* Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:
(WebCore::WHLSL::checkLiteralTypes):
* Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp:
(WebCore::WHLSL::FindAllTypes::appendNamedType):
* bindings/js/JSCallbackData.h:
* bindings/js/JSLazyEventListener.cpp:
* bindings/js/JSLazyEventListener.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::primitiveType const):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValue.cpp:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSStyleSheet.cpp:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::suspendIfNeeded):
(WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const):
* dom/ActiveDOMObject.h:
* dom/ContainerNode.cpp:
* dom/ContainerNodeAlgorithms.cpp:
* dom/ContainerNodeAlgorithms.h:
* dom/CustomElementReactionQueue.cpp:
* dom/CustomElementReactionQueue.h:
(WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope):
(WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope):
* dom/Document.cpp:
(WebCore::Document::hitTest):
* dom/Document.h:
(WebCore::Document::decrementReferencingNodeCount):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::getURLAttribute const):
(WebCore::Element::getNonEmptyURLAttribute const):
* dom/Element.h:
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::dropAssertions):
(WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack):
(WebCore::ElementAndTextDescendantIterator::traverseNextSibling):
(WebCore::ElementAndTextDescendantIterator::traversePreviousSibling):
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::ElementDescendantIterator):
(WebCore::ElementDescendantIterator::dropAssertions):
(WebCore::ElementDescendantIterator::operator++):
(WebCore::ElementDescendantIterator::operator--):
(WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator):
(WebCore::ElementDescendantConstIterator::dropAssertions):
(WebCore::ElementDescendantConstIterator::operator++):
* dom/ElementIterator.h:
(WebCore::ElementIterator<ElementType>::ElementIterator):
(WebCore::ElementIterator<ElementType>::traverseNext):
(WebCore::ElementIterator<ElementType>::traversePrevious):
(WebCore::ElementIterator<ElementType>::traverseNextSibling):
(WebCore::ElementIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementIterator<ElementType>::dropAssertions):
(WebCore::ElementIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::ElementConstIterator):
(WebCore::ElementConstIterator<ElementType>::traverseNext):
(WebCore::ElementConstIterator<ElementType>::traversePrevious):
(WebCore::ElementConstIterator<ElementType>::traverseNextSibling):
(WebCore::ElementConstIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementConstIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::dropAssertions):
* dom/EventContext.cpp:
* dom/EventContext.h:
* dom/EventListener.h:
* dom/EventPath.cpp:
* dom/EventSender.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::setAttributeEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::deref const):
* dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute const):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::resolveSlotsAfterSlotMutation):
(WebCore::SlotAssignment::findFirstSlotElement):
* dom/SlotAssignment.h:
* dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::add):
(WebCore::TreeScopeOrderedMap::get const):
* dom/TreeScopeOrderedMap.h:
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::removeAllItemsForPage):
* history/BackForwardCache.h:
* html/CanvasBase.cpp:
(WebCore::CanvasBase::notifyObserversCanvasDestroyed):
* html/CanvasBase.h:
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
* html/HTMLSelectElement.cpp:
(WebCore:: const):
* html/HTMLTableRowsCollection.cpp:
(WebCore::assertRowIsInTable):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForPosition const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::endAttribute):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::constructTree):
* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::~HTMLTreeBuilder):
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::geometryForBox const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setContentBoxHeight):
(WebCore::Display::Box::setContentBoxWidth):
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):
* layout/displaytree/DisplayInlineRect.h:
(WebCore::Display::InlineRect::InlineRect):
(WebCore::Display::InlineRect::setTopLeft):
(WebCore::Display::InlineRect::setTop):
(WebCore::Display::InlineRect::setBottom):
(WebCore::Display::InlineRect::setLeft):
(WebCore::Display::InlineRect::setWidth):
(WebCore::Display::InlineRect::setHeight):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::setBaselineOffsetIfGreater):
(WebCore::Display::LineBox::resetBaseline):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::Baseline::setAscent):
(WebCore::Display::LineBox::Baseline::setDescent):
(WebCore::Display::LineBox::Baseline::reset):
* layout/displaytree/DisplayRect.h:
(WebCore::Display::Rect::Rect):
(WebCore::Display::Rect::setTopLeft):
(WebCore::Display::Rect::setTop):
(WebCore::Display::Rect::setLeft):
(WebCore::Display::Rect::setWidth):
(WebCore::Display::Rect::setHeight):
(WebCore::Display::Rect::setSize):
(WebCore::Display::Rect::clone const):
* layout/floats/FloatingContext.cpp:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::Column::setWidthConstraints):
(WebCore::Layout::TableGrid::Column::setLogicalWidth):
(WebCore::Layout::TableGrid::Column::setLogicalLeft):
* layout/tableformatting/TableGrid.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/DocumentLoader.h:
* loader/ImageLoader.cpp:
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/FrameViewLayoutContext.cpp:
* page/FrameViewLayoutContext.h:
* page/Page.cpp:
* page/Page.h:
* page/ViewportConfiguration.cpp:
* page/ViewportConfiguration.h:
* page/mac/EventHandlerMac.mm:
(WebCore::CurrentEventScope::CurrentEventScope):
* platform/DateComponents.cpp:
(WebCore::DateComponents::toStringForTime const):
* platform/ScrollableArea.cpp:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::combineIntoOneSegment const):
* platform/SharedBuffer.h:
* platform/Supplementable.h:
* platform/Timer.cpp:
(WebCore::TimerBase::checkHeapIndex const):
(WebCore::TimerBase::updateHeapIfNeeded):
* platform/graphics/BitmapImage.cpp:
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::ScratchBuffer):
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ScratchBuffer::scheduleScratchBufferPurge):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::setWindow):
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp:
(gstAllocatorFastMallocFree):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createTile):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::fill):
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::appendGeometry):
(WebCore::Path::Path):
(WebCore::Path::operator=):
(WebCore::Path::strokeContains const):
(WebCore::Path::transform):
* platform/graphics/win/PlatformContextDirect2D.cpp:
(WebCore::PlatformContextDirect2D::setTags):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
* platform/network/HTTPParsers.cpp:
(WebCore::isCrossOriginSafeHeader):
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::SQLiteStatement):
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::finalize):
* platform/sql/SQLiteStatement.h:
* platform/win/COMPtr.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::removeInlineBox const):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
(WebCore::FloatingObjects::addPlacedObject):
(WebCore::FloatingObjects::removePlacedObject):
* rendering/FloatingObjects.h:
* rendering/GridTrackSizingAlgorithm.cpp:
* rendering/GridTrackSizingAlgorithm.h:
* rendering/LayoutDisallowedScope.cpp:
* rendering/LayoutDisallowedScope.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderElement.cpp:
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::baselinePosition const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::ClipRectsCache::ClipRectsCache):
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::traverseVisibleNonCompositedDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const):
(WebCore::RenderLayerCompositor::recursiveRepaintLayer):
(WebCore::RenderLayerCompositor::layerHas3DContent const):
* rendering/RenderLayoutState.cpp:
(WebCore::RenderLayoutState::RenderLayoutState):
(WebCore::RenderLayoutState::computeOffsets):
(WebCore::RenderLayoutState::addLayoutDelta):
* rendering/RenderLayoutState.h:
(WebCore::RenderLayoutState::RenderLayoutState):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::~RenderObject):
(WebCore::RenderObject::clearNeedsLayout):
* rendering/RenderObject.h:
* rendering/RenderQuote.cpp:
(WebCore::quotesForLanguage):
* rendering/RenderTableCell.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::computeOverflowFromCells):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::checkConsistency const):
* rendering/RenderTextLineBoxes.h:
* rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::~RenderStyle):
* rendering/style/RenderStyle.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::detach):
* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):
* rendering/updating/RenderTreePosition.h:
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::firstGlyph const):
(WebCore::SVGToOTFFontConverter::appendKERNTable):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::SVGTransformDistance):
(WebCore::SVGTransformDistance::scaledDistance const):
(WebCore::SVGTransformDistance::addSVGTransforms):
(WebCore::SVGTransformDistance::addToSVGTransform const):
(WebCore::SVGTransformDistance::distance const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
* testing/InternalSettings.cpp:
* workers/service/ServiceWorkerJob.h:
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* xml/XPathStep.cpp:
Source/WebKit:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::invalidateAndCancel):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::setCapacity):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* Platform/IPC/Connection.cpp:
(IPC::Connection::waitForMessage):
* Platform/IPC/MessageReceiver.h:
(IPC::MessageReceiver::willBeAddedToMessageReceiverMap):
(IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::readFromMachPort):
* Platform/mac/MachUtilities.cpp:
(setMachExceptionPort):
* Shared/API/APIClient.h:
(API::Client::Client):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
* Shared/Cocoa/ArgumentCodersCocoa.h:
* Shared/SharedStringHashTableReadOnly.cpp:
* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/GenericCallback.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Transaction::Token::Token):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy):
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runModal):
* WebProcess/WebProcess.cpp:
(WebKit::checkDocumentsCaptureStateConsistency):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateProcessName):
Source/WebKitLegacy:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::StorageAreaImpl):
(WebKit::StorageAreaImpl::close):
* Storage/StorageAreaImpl.h:
Source/WebKitLegacy/mac:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* History/WebHistory.mm:
(-[WebHistoryPrivate removeItemForURLString:]):
* WebView/WebFrame.mm:
Source/WebKitLegacy/win:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::swapChain):
(WKQCA::CAD3DRenderer::initialize):
* WebKitQuartzCoreAdditions/CAD3DRenderer.h:
* WebView.cpp:
(WebView::Release):
* WebView.h:
Source/WTF:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
This patch did the following changes:
1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away
with the need for the double negative !ASSERT_DISABLED test that is commonly
used all over the code, thereby improving code readability.
In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED,
ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and
RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents
as well. We'll do that in another patch. For now, they are left as is to
minimize the size of this patch.
See https://bugs.webkit.org/show_bug.cgi?id=205780.
2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be
guarded by "#if ASSERT_ENABLED" instead.
3. In cases where the change is minimal, we move some code around so that we can
test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED".
* wtf/Assertions.h:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/BitVector.h:
* wtf/BlockObjCExceptions.mm:
(ReportBlockedObjCException):
* wtf/BloomFilter.h:
* wtf/CallbackAggregator.h:
(WTF::CallbackAggregator::CallbackAggregator):
* wtf/CheckedArithmetic.h:
(WTF::observesOverflow<AssertNoOverflow>):
* wtf/CheckedBoolean.h:
(CheckedBoolean::CheckedBoolean):
(CheckedBoolean::operator bool):
* wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* wtf/DateMath.cpp:
(WTF::initializeDates):
* wtf/Gigacage.cpp:
(Gigacage::tryAllocateZeroedVirtualPages):
* wtf/HashTable.h:
(WTF::KeyTraits>::checkKey):
(WTF::KeyTraits>::checkTableConsistencyExceptSize const):
* wtf/LoggerHelper.h:
* wtf/NaturalLoops.h:
(WTF::NaturalLoops::headerOf const):
* wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
* wtf/Platform.h:
* wtf/PtrTag.h:
* wtf/RefCounted.h:
(WTF::RefCountedBase::disableThreadingChecks):
(WTF::RefCountedBase::enableThreadingChecksGlobally):
(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
* wtf/SingleRootGraph.h:
(WTF::SingleRootGraph::assertIsConsistent const):
* wtf/SizeLimits.cpp:
* wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::domainToASCII):
* wtf/ValueCheck.h:
* wtf/Vector.h:
(WTF::Malloc>::checkConsistency):
* wtf/WeakHashSet.h:
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::WeakPtrImpl):
(WTF::WeakPtrFactory::WeakPtrFactory):
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringImpl.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString const):
* wtf/text/StringBuilder.h:
* wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* wtf/text/StringHasher.h:
(WTF::StringHasher::addCharacters):
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
Tools:
Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory
https://bugs.webkit.org/show_bug.cgi?id=205754
Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06
Reviewed by Youenn Fablet.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::websiteDataStore):
(WTR::TestController::platformAdjustContext):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
Canonical link: https://commits.webkit.org/218957@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
|
|
|
#if ASSERT_ENABLED
|
2016-09-08 17:23:30 +00:00
|
|
|
for (int32_t i = 0; i < numCharactersConverted; ++i) {
|
|
|
|
ASSERT(isASCII(hostnameBuffer[i]));
|
2016-09-20 21:50:30 +00:00
|
|
|
ASSERT(!isASCIIUpper(hostnameBuffer[i]));
|
2016-09-08 17:23:30 +00:00
|
|
|
}
|
PerformanceTests:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* JetStream2/wasm/HashSet.cpp:
* StitchMarker/wtf/Assertions.h:
* StitchMarker/wtf/DateMath.cpp:
(WTF::initializeDates):
* StitchMarker/wtf/HashTable.h:
* StitchMarker/wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
* StitchMarker/wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* StitchMarker/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* StitchMarker/wtf/ValueCheck.h:
* StitchMarker/wtf/Vector.h:
(WTF::minCapacity>::checkConsistency):
* StitchMarker/wtf/text/AtomicStringImpl.cpp:
* StitchMarker/wtf/text/AtomicStringImpl.h:
* StitchMarker/wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* StitchMarker/wtf/text/StringImpl.h:
* StitchMarker/wtf/text/SymbolImpl.h:
* StitchMarker/wtf/text/UniquedStringImpl.h:
Source/JavaScriptCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* API/tests/testapi.c:
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithLoad):
(JSC::ARM64Assembler::replaceWithAddressComputation):
* assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::LocalWriter::LocalWriter):
* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::Stack):
* assembler/ProbeStack.h:
* b3/B3FoldPathConstants.cpp:
* b3/B3LowerToAir.cpp:
* b3/B3MemoryValue.cpp:
(JSC::B3::MemoryValue::MemoryValue):
* b3/B3Opcode.cpp:
* b3/B3Type.h:
* b3/B3TypeMap.h:
* b3/B3Width.h:
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration):
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.h:
* b3/air/AirAllocateRegistersByGraphColoring.cpp:
* b3/air/AirArg.cpp:
* b3/air/AirArg.h:
* b3/air/AirCode.h:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/AccessCase.cpp:
* bytecode/AccessCase.h:
* bytecode/CallVariant.cpp:
(JSC::variantListWithVariant):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex):
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::dump const):
* bytecode/StructureStubInfo.cpp:
* bytecode/StructureStubInfo.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionCallResolveNode::emitBytecode):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
* debugger/Debugger.cpp:
(JSC::Debugger::removeBreakpoint):
* debugger/DebuggerEvalEnabler.h:
(JSC::DebuggerEvalEnabler::DebuggerEvalEnabler):
(JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions):
* dfg/DFGAbstractValue.cpp:
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::merge):
(JSC::DFG::AbstractValue::checkConsistency const):
(JSC::DFG::AbstractValue::assertIsRegistered const):
* dfg/DFGArithMode.h:
(JSC::DFG::doesOverflow):
* dfg/DFGBasicBlock.cpp:
(JSC::DFG::BasicBlock::BasicBlock):
* dfg/DFGBasicBlock.h:
(JSC::DFG::BasicBlock::didLink):
* dfg/DFGCFAPhase.cpp:
(JSC::DFG::CFAPhase::performBlockCFA):
* dfg/DFGCommon.h:
(JSC::DFG::validationEnabled):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGEdge.h:
(JSC::DFG::Edge::makeWord):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::assertClear):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::SlowPathGenerator::generate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
(JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse):
(JSC::DFG::SpeculativeJIT::emitAllocateButterfly):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
* dfg/DFGStructureAbstractValue.cpp:
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::assertIsRegistered const):
* dfg/DFGVarargsForwardingPhase.cpp:
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::callPreflight):
(JSC::FTL::DFG::LowerDFGToB3::callCheck):
(JSC::FTL::DFG::LowerDFGToB3::crash):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::assertNoUnswept):
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::validatePrevious):
* heap/HandleSet.cpp:
* heap/HandleSet.h:
* heap/Heap.cpp:
(JSC::Heap::updateAllocationLimits):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::assertValidCell const):
(JSC::MarkedBlock::assertMarksNotStale):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::beginMarking):
(JSC::MarkedSpace::endMarking):
(JSC::MarkedSpace::assertNoUnswept):
* heap/PreciseAllocation.cpp:
* heap/PreciseAllocation.h:
(JSC::PreciseAllocation::assertValidCell const):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
* heap/SlotVisitor.h:
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
(CppProtocolTypesImplementationGenerator):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* interpreter/FrameTracers.h:
(JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
* interpreter/Interpreter.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::prepareCallOperation):
* jit/BinarySwitch.cpp:
(JSC::BinarySwitch::BinarySwitch):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupStubArgs):
* jit/CallFrameShuffler.cpp:
(JSC::CallFrameShuffler::emitDeltaCheck):
(JSC::CallFrameShuffler::prepareAny):
* jit/JIT.cpp:
(JSC::JIT::assertStackPointerOffset):
(JSC::JIT::compileWithoutLinking):
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_loop_hint):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jit/ThunkGenerators.cpp:
(JSC::emitPointerValidation):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LLIntOfflineAsmConfig.h:
* parser/Lexer.cpp:
* parser/Lexer.h:
(JSC::isSafeBuiltinIdentifier):
(JSC::Lexer<T>::lexExpectIdentifier):
* runtime/ArgList.h:
(JSC::MarkedArgumentBuffer::setNeedsOverflowCheck):
(JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck):
* runtime/Butterfly.h:
(JSC::ContiguousData::ContiguousData):
(JSC::ContiguousData::Data::Data):
* runtime/HashMapImpl.h:
(JSC::HashMapImpl::checkConsistency const):
(JSC::HashMapImpl::assertBufferIsEmpty const):
* runtime/JSCellInlines.h:
(JSC::JSCell::methodTable const):
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
(JSC::JSFunction::assertTypeInfoFlagInvariants):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren):
(JSC::JSFinalObject::visitChildren):
* runtime/JSObjectInlines.h:
(JSC::JSObject::validatePutOwnDataProperty):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::assertVariableIsInThisObject):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lex):
* runtime/LiteralParser.h:
* runtime/Operations.h:
(JSC::scribbleFreeCells):
* runtime/OptionsList.h:
* runtime/VM.cpp:
(JSC::VM::computeCanUseJIT):
* runtime/VM.h:
(JSC::VM::canUseJIT):
* runtime/VarOffset.h:
(JSC::VarOffset::checkSanity const):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::checkConsistency const):
(JSC::WeakMapImpl::assertBufferIsEmpty const):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::validateInst):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::validationFail const):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::checkConsistency):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast):
* wasm/WasmSectionParser.h:
* wasm/WasmSections.h:
* wasm/WasmSignatureInlines.h:
(JSC::Wasm::SignatureInformation::get):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::enqueue):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::previousInstanceOffset const):
Source/WebCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTask::performTask):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::terminationRequested const):
* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h:
(WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation):
* Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp:
(WebCore::WHLSL::findHighZombies):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::matches):
* Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:
(WebCore::WHLSL::checkLiteralTypes):
* Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp:
(WebCore::WHLSL::FindAllTypes::appendNamedType):
* bindings/js/JSCallbackData.h:
* bindings/js/JSLazyEventListener.cpp:
* bindings/js/JSLazyEventListener.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::primitiveType const):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValue.cpp:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSStyleSheet.cpp:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::suspendIfNeeded):
(WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const):
* dom/ActiveDOMObject.h:
* dom/ContainerNode.cpp:
* dom/ContainerNodeAlgorithms.cpp:
* dom/ContainerNodeAlgorithms.h:
* dom/CustomElementReactionQueue.cpp:
* dom/CustomElementReactionQueue.h:
(WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope):
(WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope):
* dom/Document.cpp:
(WebCore::Document::hitTest):
* dom/Document.h:
(WebCore::Document::decrementReferencingNodeCount):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::getURLAttribute const):
(WebCore::Element::getNonEmptyURLAttribute const):
* dom/Element.h:
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::dropAssertions):
(WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack):
(WebCore::ElementAndTextDescendantIterator::traverseNextSibling):
(WebCore::ElementAndTextDescendantIterator::traversePreviousSibling):
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::ElementDescendantIterator):
(WebCore::ElementDescendantIterator::dropAssertions):
(WebCore::ElementDescendantIterator::operator++):
(WebCore::ElementDescendantIterator::operator--):
(WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator):
(WebCore::ElementDescendantConstIterator::dropAssertions):
(WebCore::ElementDescendantConstIterator::operator++):
* dom/ElementIterator.h:
(WebCore::ElementIterator<ElementType>::ElementIterator):
(WebCore::ElementIterator<ElementType>::traverseNext):
(WebCore::ElementIterator<ElementType>::traversePrevious):
(WebCore::ElementIterator<ElementType>::traverseNextSibling):
(WebCore::ElementIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementIterator<ElementType>::dropAssertions):
(WebCore::ElementIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::ElementConstIterator):
(WebCore::ElementConstIterator<ElementType>::traverseNext):
(WebCore::ElementConstIterator<ElementType>::traversePrevious):
(WebCore::ElementConstIterator<ElementType>::traverseNextSibling):
(WebCore::ElementConstIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementConstIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::dropAssertions):
* dom/EventContext.cpp:
* dom/EventContext.h:
* dom/EventListener.h:
* dom/EventPath.cpp:
* dom/EventSender.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::setAttributeEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::deref const):
* dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute const):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::resolveSlotsAfterSlotMutation):
(WebCore::SlotAssignment::findFirstSlotElement):
* dom/SlotAssignment.h:
* dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::add):
(WebCore::TreeScopeOrderedMap::get const):
* dom/TreeScopeOrderedMap.h:
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::removeAllItemsForPage):
* history/BackForwardCache.h:
* html/CanvasBase.cpp:
(WebCore::CanvasBase::notifyObserversCanvasDestroyed):
* html/CanvasBase.h:
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
* html/HTMLSelectElement.cpp:
(WebCore:: const):
* html/HTMLTableRowsCollection.cpp:
(WebCore::assertRowIsInTable):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForPosition const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::endAttribute):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::constructTree):
* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::~HTMLTreeBuilder):
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::geometryForBox const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setContentBoxHeight):
(WebCore::Display::Box::setContentBoxWidth):
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):
* layout/displaytree/DisplayInlineRect.h:
(WebCore::Display::InlineRect::InlineRect):
(WebCore::Display::InlineRect::setTopLeft):
(WebCore::Display::InlineRect::setTop):
(WebCore::Display::InlineRect::setBottom):
(WebCore::Display::InlineRect::setLeft):
(WebCore::Display::InlineRect::setWidth):
(WebCore::Display::InlineRect::setHeight):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::setBaselineOffsetIfGreater):
(WebCore::Display::LineBox::resetBaseline):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::Baseline::setAscent):
(WebCore::Display::LineBox::Baseline::setDescent):
(WebCore::Display::LineBox::Baseline::reset):
* layout/displaytree/DisplayRect.h:
(WebCore::Display::Rect::Rect):
(WebCore::Display::Rect::setTopLeft):
(WebCore::Display::Rect::setTop):
(WebCore::Display::Rect::setLeft):
(WebCore::Display::Rect::setWidth):
(WebCore::Display::Rect::setHeight):
(WebCore::Display::Rect::setSize):
(WebCore::Display::Rect::clone const):
* layout/floats/FloatingContext.cpp:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::Column::setWidthConstraints):
(WebCore::Layout::TableGrid::Column::setLogicalWidth):
(WebCore::Layout::TableGrid::Column::setLogicalLeft):
* layout/tableformatting/TableGrid.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/DocumentLoader.h:
* loader/ImageLoader.cpp:
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/FrameViewLayoutContext.cpp:
* page/FrameViewLayoutContext.h:
* page/Page.cpp:
* page/Page.h:
* page/ViewportConfiguration.cpp:
* page/ViewportConfiguration.h:
* page/mac/EventHandlerMac.mm:
(WebCore::CurrentEventScope::CurrentEventScope):
* platform/DateComponents.cpp:
(WebCore::DateComponents::toStringForTime const):
* platform/ScrollableArea.cpp:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::combineIntoOneSegment const):
* platform/SharedBuffer.h:
* platform/Supplementable.h:
* platform/Timer.cpp:
(WebCore::TimerBase::checkHeapIndex const):
(WebCore::TimerBase::updateHeapIfNeeded):
* platform/graphics/BitmapImage.cpp:
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::ScratchBuffer):
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ScratchBuffer::scheduleScratchBufferPurge):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::setWindow):
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp:
(gstAllocatorFastMallocFree):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createTile):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::fill):
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::appendGeometry):
(WebCore::Path::Path):
(WebCore::Path::operator=):
(WebCore::Path::strokeContains const):
(WebCore::Path::transform):
* platform/graphics/win/PlatformContextDirect2D.cpp:
(WebCore::PlatformContextDirect2D::setTags):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
* platform/network/HTTPParsers.cpp:
(WebCore::isCrossOriginSafeHeader):
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::SQLiteStatement):
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::finalize):
* platform/sql/SQLiteStatement.h:
* platform/win/COMPtr.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::removeInlineBox const):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
(WebCore::FloatingObjects::addPlacedObject):
(WebCore::FloatingObjects::removePlacedObject):
* rendering/FloatingObjects.h:
* rendering/GridTrackSizingAlgorithm.cpp:
* rendering/GridTrackSizingAlgorithm.h:
* rendering/LayoutDisallowedScope.cpp:
* rendering/LayoutDisallowedScope.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderElement.cpp:
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::baselinePosition const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::ClipRectsCache::ClipRectsCache):
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::traverseVisibleNonCompositedDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const):
(WebCore::RenderLayerCompositor::recursiveRepaintLayer):
(WebCore::RenderLayerCompositor::layerHas3DContent const):
* rendering/RenderLayoutState.cpp:
(WebCore::RenderLayoutState::RenderLayoutState):
(WebCore::RenderLayoutState::computeOffsets):
(WebCore::RenderLayoutState::addLayoutDelta):
* rendering/RenderLayoutState.h:
(WebCore::RenderLayoutState::RenderLayoutState):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::~RenderObject):
(WebCore::RenderObject::clearNeedsLayout):
* rendering/RenderObject.h:
* rendering/RenderQuote.cpp:
(WebCore::quotesForLanguage):
* rendering/RenderTableCell.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::computeOverflowFromCells):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::checkConsistency const):
* rendering/RenderTextLineBoxes.h:
* rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::~RenderStyle):
* rendering/style/RenderStyle.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::detach):
* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):
* rendering/updating/RenderTreePosition.h:
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::firstGlyph const):
(WebCore::SVGToOTFFontConverter::appendKERNTable):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::SVGTransformDistance):
(WebCore::SVGTransformDistance::scaledDistance const):
(WebCore::SVGTransformDistance::addSVGTransforms):
(WebCore::SVGTransformDistance::addToSVGTransform const):
(WebCore::SVGTransformDistance::distance const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
* testing/InternalSettings.cpp:
* workers/service/ServiceWorkerJob.h:
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* xml/XPathStep.cpp:
Source/WebKit:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::invalidateAndCancel):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::setCapacity):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* Platform/IPC/Connection.cpp:
(IPC::Connection::waitForMessage):
* Platform/IPC/MessageReceiver.h:
(IPC::MessageReceiver::willBeAddedToMessageReceiverMap):
(IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::readFromMachPort):
* Platform/mac/MachUtilities.cpp:
(setMachExceptionPort):
* Shared/API/APIClient.h:
(API::Client::Client):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
* Shared/Cocoa/ArgumentCodersCocoa.h:
* Shared/SharedStringHashTableReadOnly.cpp:
* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/GenericCallback.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Transaction::Token::Token):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy):
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runModal):
* WebProcess/WebProcess.cpp:
(WebKit::checkDocumentsCaptureStateConsistency):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateProcessName):
Source/WebKitLegacy:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::StorageAreaImpl):
(WebKit::StorageAreaImpl::close):
* Storage/StorageAreaImpl.h:
Source/WebKitLegacy/mac:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* History/WebHistory.mm:
(-[WebHistoryPrivate removeItemForURLString:]):
* WebView/WebFrame.mm:
Source/WebKitLegacy/win:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::swapChain):
(WKQCA::CAD3DRenderer::initialize):
* WebKitQuartzCoreAdditions/CAD3DRenderer.h:
* WebView.cpp:
(WebView::Release):
* WebView.h:
Source/WTF:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
This patch did the following changes:
1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away
with the need for the double negative !ASSERT_DISABLED test that is commonly
used all over the code, thereby improving code readability.
In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED,
ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and
RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents
as well. We'll do that in another patch. For now, they are left as is to
minimize the size of this patch.
See https://bugs.webkit.org/show_bug.cgi?id=205780.
2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be
guarded by "#if ASSERT_ENABLED" instead.
3. In cases where the change is minimal, we move some code around so that we can
test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED".
* wtf/Assertions.h:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/BitVector.h:
* wtf/BlockObjCExceptions.mm:
(ReportBlockedObjCException):
* wtf/BloomFilter.h:
* wtf/CallbackAggregator.h:
(WTF::CallbackAggregator::CallbackAggregator):
* wtf/CheckedArithmetic.h:
(WTF::observesOverflow<AssertNoOverflow>):
* wtf/CheckedBoolean.h:
(CheckedBoolean::CheckedBoolean):
(CheckedBoolean::operator bool):
* wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* wtf/DateMath.cpp:
(WTF::initializeDates):
* wtf/Gigacage.cpp:
(Gigacage::tryAllocateZeroedVirtualPages):
* wtf/HashTable.h:
(WTF::KeyTraits>::checkKey):
(WTF::KeyTraits>::checkTableConsistencyExceptSize const):
* wtf/LoggerHelper.h:
* wtf/NaturalLoops.h:
(WTF::NaturalLoops::headerOf const):
* wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
* wtf/Platform.h:
* wtf/PtrTag.h:
* wtf/RefCounted.h:
(WTF::RefCountedBase::disableThreadingChecks):
(WTF::RefCountedBase::enableThreadingChecksGlobally):
(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
* wtf/SingleRootGraph.h:
(WTF::SingleRootGraph::assertIsConsistent const):
* wtf/SizeLimits.cpp:
* wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::domainToASCII):
* wtf/ValueCheck.h:
* wtf/Vector.h:
(WTF::Malloc>::checkConsistency):
* wtf/WeakHashSet.h:
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::WeakPtrImpl):
(WTF::WeakPtrFactory::WeakPtrFactory):
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringImpl.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString const):
* wtf/text/StringBuilder.h:
* wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* wtf/text/StringHasher.h:
(WTF::StringHasher::addCharacters):
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
Tools:
Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory
https://bugs.webkit.org/show_bug.cgi?id=205754
Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06
Reviewed by Youenn Fablet.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::websiteDataStore):
(WTR::TestController::platformAdjustContext):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
Canonical link: https://commits.webkit.org/218957@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
|
|
|
#else
|
|
|
|
UNUSED_PARAM(numCharactersConverted);
|
|
|
|
#endif // ASSERT_ENABLED
|
2016-09-20 21:50:30 +00:00
|
|
|
ascii.append(hostnameBuffer, numCharactersConverted);
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
if (domain != StringView(ascii.data(), ascii.size()))
|
|
|
|
syntaxViolation(iteratorForSyntaxViolationPosition);
|
2016-09-20 21:50:30 +00:00
|
|
|
return ascii;
|
2016-09-08 17:23:30 +00:00
|
|
|
}
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2016-09-06 18:16:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-30 21:17:59 +00:00
|
|
|
bool URLParser::hasForbiddenHostCodePoint(const URLParser::LCharBuffer& asciiDomain)
|
2016-09-06 18:16:07 +00:00
|
|
|
{
|
2016-09-20 21:50:30 +00:00
|
|
|
for (size_t i = 0; i < asciiDomain.size(); ++i) {
|
2017-02-13 22:52:34 +00:00
|
|
|
if (isForbiddenHostCodePoint(asciiDomain[i]))
|
2016-09-06 18:16:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-09-23 19:57:57 +00:00
|
|
|
template<typename CharacterType>
|
2016-09-15 18:12:09 +00:00
|
|
|
bool URLParser::parsePort(CodePointIterator<CharacterType>& iterator)
|
2016-09-06 18:16:07 +00:00
|
|
|
{
|
2020-10-14 20:00:44 +00:00
|
|
|
if (UNLIKELY(m_urlIsFile))
|
|
|
|
return false;
|
|
|
|
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
ASSERT(*iterator == ':');
|
|
|
|
auto colonIterator = iterator;
|
|
|
|
advance(iterator, colonIterator);
|
2016-09-06 18:16:07 +00:00
|
|
|
uint32_t port = 0;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (UNLIKELY(iterator.atEnd())) {
|
2018-07-13 00:28:36 +00:00
|
|
|
unsigned portLength = currentPosition(colonIterator) - m_url.m_hostEnd;
|
|
|
|
RELEASE_ASSERT(portLength <= URL::maxPortLength);
|
|
|
|
m_url.m_portLength = portLength;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(colonIterator);
|
2016-09-08 22:28:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-09-29 21:25:14 +00:00
|
|
|
size_t digitCount = 0;
|
2016-09-29 21:20:43 +00:00
|
|
|
bool leadingZeros = false;
|
2016-09-15 18:12:09 +00:00
|
|
|
for (; !iterator.atEnd(); ++iterator) {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (UNLIKELY(isTabOrNewline(*iterator))) {
|
|
|
|
syntaxViolation(colonIterator);
|
2016-09-06 18:16:07 +00:00
|
|
|
continue;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
}
|
2016-09-06 18:16:07 +00:00
|
|
|
if (isASCIIDigit(*iterator)) {
|
2016-09-29 21:25:14 +00:00
|
|
|
if (*iterator == '0' && !digitCount)
|
2016-09-29 21:20:43 +00:00
|
|
|
leadingZeros = true;
|
2016-09-29 21:25:14 +00:00
|
|
|
++digitCount;
|
2016-09-06 18:16:07 +00:00
|
|
|
port = port * 10 + *iterator - '0';
|
|
|
|
if (port > std::numeric_limits<uint16_t>::max())
|
|
|
|
return false;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-16 20:35:16 +00:00
|
|
|
|
2016-09-29 21:20:43 +00:00
|
|
|
if (port && leadingZeros)
|
|
|
|
syntaxViolation(colonIterator);
|
|
|
|
|
2016-09-29 21:25:14 +00:00
|
|
|
if (!port && digitCount > 1)
|
2016-09-29 21:20:43 +00:00
|
|
|
syntaxViolation(colonIterator);
|
|
|
|
|
2016-11-04 23:59:03 +00:00
|
|
|
ASSERT(port == static_cast<uint16_t>(port));
|
|
|
|
if (UNLIKELY(defaultPortForProtocol(parsedDataView(0, m_url.m_schemeEnd)) == static_cast<uint16_t>(port)))
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(colonIterator);
|
|
|
|
else {
|
|
|
|
appendToASCIIBuffer(':');
|
2016-09-23 23:40:46 +00:00
|
|
|
ASSERT(port <= std::numeric_limits<uint16_t>::max());
|
|
|
|
appendNumberToASCIIBuffer<uint16_t>(static_cast<uint16_t>(port));
|
|
|
|
}
|
2016-09-06 18:16:07 +00:00
|
|
|
|
2018-07-13 00:28:36 +00:00
|
|
|
unsigned portLength = currentPosition(iterator) - m_url.m_hostEnd;
|
|
|
|
RELEASE_ASSERT(portLength <= URL::maxPortLength);
|
|
|
|
m_url.m_portLength = portLength;
|
2016-09-06 18:16:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-10-05 14:51:18 +00:00
|
|
|
template<typename CharacterType>
|
2021-06-15 16:59:15 +00:00
|
|
|
bool URLParser::subdomainStartsWithXNDashDash(CodePointIterator<CharacterType> iterator)
|
2020-10-05 14:51:18 +00:00
|
|
|
{
|
2021-06-15 16:59:15 +00:00
|
|
|
enum class State : uint8_t {
|
|
|
|
NotAtSubdomainBeginOrInXNDashDash,
|
|
|
|
AtSubdomainBegin,
|
|
|
|
AfterX,
|
|
|
|
AfterN,
|
|
|
|
AfterFirstDash,
|
|
|
|
} state { State::AtSubdomainBegin };
|
|
|
|
|
|
|
|
for (; !iterator.atEnd(); advance<CharacterType, ReportSyntaxViolation::No>(iterator)) {
|
|
|
|
CharacterType c = *iterator;
|
|
|
|
|
|
|
|
// These characters indicate the end of the host.
|
|
|
|
if (c == ':' || c == '/' || c == '?' || c == '#')
|
|
|
|
return false;
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case State::NotAtSubdomainBeginOrInXNDashDash:
|
|
|
|
break;
|
|
|
|
case State::AtSubdomainBegin:
|
|
|
|
if (c == 'x' || c == 'X') {
|
|
|
|
state = State::AfterX;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case State::AfterX:
|
|
|
|
if (c == 'n' || c == 'N') {
|
|
|
|
state = State::AfterN;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case State::AfterN:
|
|
|
|
if (c == '-') {
|
|
|
|
state = State::AfterFirstDash;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case State::AfterFirstDash:
|
|
|
|
if (c == '-')
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c == '.')
|
|
|
|
state = State::AtSubdomainBegin;
|
|
|
|
else
|
|
|
|
state = State::NotAtSubdomainBeginOrInXNDashDash;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool URLParser::subdomainStartsWithXNDashDash(StringImpl& host)
|
|
|
|
{
|
|
|
|
if (host.is8Bit()) {
|
|
|
|
const LChar* begin = host.characters8();
|
|
|
|
return subdomainStartsWithXNDashDash(CodePointIterator<LChar>(begin, begin + host.length()));
|
|
|
|
}
|
|
|
|
const UChar* begin = host.characters16();
|
|
|
|
return subdomainStartsWithXNDashDash(CodePointIterator<UChar>(begin, begin + host.length()));
|
2020-10-05 14:51:18 +00:00
|
|
|
}
|
|
|
|
|
2016-09-23 19:57:57 +00:00
|
|
|
template<typename CharacterType>
|
2016-10-13 21:01:58 +00:00
|
|
|
bool URLParser::parseHostAndPort(CodePointIterator<CharacterType> iterator)
|
2016-08-17 00:41:30 +00:00
|
|
|
{
|
2016-09-15 18:12:09 +00:00
|
|
|
if (iterator.atEnd())
|
2016-09-03 00:32:49 +00:00
|
|
|
return false;
|
2016-09-30 18:48:28 +00:00
|
|
|
if (*iterator == ':')
|
|
|
|
return false;
|
2016-08-22 05:42:12 +00:00
|
|
|
if (*iterator == '[') {
|
2016-09-01 00:23:47 +00:00
|
|
|
auto ipv6End = iterator;
|
2016-09-15 18:12:09 +00:00
|
|
|
while (!ipv6End.atEnd() && *ipv6End != ']')
|
2016-09-01 00:23:47 +00:00
|
|
|
++ipv6End;
|
2016-09-29 18:19:31 +00:00
|
|
|
if (ipv6End.atEnd())
|
|
|
|
return false;
|
2016-09-15 18:12:09 +00:00
|
|
|
if (auto address = parseIPv6Host(CodePointIterator<CharacterType>(iterator, ipv6End))) {
|
2016-09-23 23:40:46 +00:00
|
|
|
serializeIPv6(address.value());
|
2016-09-15 18:12:09 +00:00
|
|
|
if (!ipv6End.atEnd()) {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
advance(ipv6End);
|
|
|
|
m_url.m_hostEnd = currentPosition(ipv6End);
|
2019-05-31 20:55:25 +00:00
|
|
|
if (!ipv6End.atEnd() && *ipv6End == ':')
|
|
|
|
return parsePort(ipv6End);
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2019-05-31 20:55:25 +00:00
|
|
|
return ipv6End.atEnd();
|
2016-09-08 22:28:48 +00:00
|
|
|
}
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
m_url.m_hostEnd = currentPosition(ipv6End);
|
2016-09-03 00:32:49 +00:00
|
|
|
return true;
|
2016-09-01 00:23:47 +00:00
|
|
|
}
|
2016-11-01 21:31:40 +00:00
|
|
|
return false;
|
2016-08-22 05:42:12 +00:00
|
|
|
}
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
|
2016-11-01 21:31:40 +00:00
|
|
|
if (!m_urlIsSpecial) {
|
|
|
|
for (; !iterator.atEnd(); ++iterator) {
|
|
|
|
if (UNLIKELY(isTabOrNewline(*iterator))) {
|
|
|
|
syntaxViolation(iterator);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (*iterator == ':')
|
|
|
|
break;
|
2017-02-13 22:52:34 +00:00
|
|
|
if (UNLIKELY(isForbiddenHostCodePoint(*iterator) && *iterator != '%'))
|
2017-02-03 17:44:30 +00:00
|
|
|
return false;
|
2016-11-01 21:31:40 +00:00
|
|
|
utf8PercentEncode<isInSimpleEncodeSet>(iterator);
|
|
|
|
}
|
|
|
|
m_url.m_hostEnd = currentPosition(iterator);
|
|
|
|
if (iterator.atEnd()) {
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-11-01 21:31:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return parsePort(iterator);
|
|
|
|
}
|
|
|
|
|
2021-06-15 16:59:15 +00:00
|
|
|
if (LIKELY(!m_hostHasPercentOrNonASCII && !subdomainStartsWithXNDashDash(iterator))) {
|
2016-09-14 19:34:53 +00:00
|
|
|
auto hostIterator = iterator;
|
2016-09-15 18:12:09 +00:00
|
|
|
for (; !iterator.atEnd(); ++iterator) {
|
2016-09-23 19:57:57 +00:00
|
|
|
if (isTabOrNewline(*iterator))
|
2016-09-14 19:34:53 +00:00
|
|
|
continue;
|
|
|
|
if (*iterator == ':')
|
|
|
|
break;
|
2017-02-13 22:52:34 +00:00
|
|
|
if (isForbiddenHostCodePoint(*iterator))
|
2016-09-15 18:20:33 +00:00
|
|
|
return false;
|
2016-09-14 19:34:53 +00:00
|
|
|
}
|
2017-02-14 07:43:28 +00:00
|
|
|
auto address = parseIPv4Host(hostIterator, CodePointIterator<CharacterType>(hostIterator, iterator));
|
|
|
|
if (address) {
|
2016-11-01 21:31:40 +00:00
|
|
|
serializeIPv4(address.value());
|
|
|
|
m_url.m_hostEnd = currentPosition(iterator);
|
|
|
|
if (iterator.atEnd()) {
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-11-01 21:31:40 +00:00
|
|
|
return true;
|
2016-09-14 19:34:53 +00:00
|
|
|
}
|
2016-11-01 21:31:40 +00:00
|
|
|
return parsePort(iterator);
|
2016-09-14 19:34:53 +00:00
|
|
|
}
|
2017-02-14 07:43:28 +00:00
|
|
|
if (address.error() == IPv4ParsingError::Failure)
|
|
|
|
return false;
|
2016-09-14 19:34:53 +00:00
|
|
|
for (; hostIterator != iterator; ++hostIterator) {
|
2016-10-29 00:17:01 +00:00
|
|
|
if (UNLIKELY(isTabOrNewline(*hostIterator))) {
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
syntaxViolation(hostIterator);
|
2016-10-29 00:17:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-11-01 21:31:40 +00:00
|
|
|
if (UNLIKELY(isASCIIUpper(*hostIterator)))
|
|
|
|
syntaxViolation(hostIterator);
|
|
|
|
appendToASCIIBuffer(toASCIILower(*hostIterator));
|
2016-09-14 19:34:53 +00:00
|
|
|
}
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_hostEnd = currentPosition(iterator);
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (!hostIterator.atEnd())
|
2016-09-23 19:57:57 +00:00
|
|
|
return parsePort(hostIterator);
|
2018-07-13 00:28:36 +00:00
|
|
|
unsigned portLength = currentPosition(iterator) - m_url.m_hostEnd;
|
|
|
|
RELEASE_ASSERT(portLength <= URL::maxPortLength);
|
|
|
|
m_url.m_portLength = portLength;
|
2016-09-14 19:34:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-09-20 21:50:30 +00:00
|
|
|
|
2017-02-03 06:30:30 +00:00
|
|
|
const auto hostBegin = iterator;
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
|
2018-04-30 21:17:59 +00:00
|
|
|
LCharBuffer utf8Encoded;
|
2016-09-15 18:12:09 +00:00
|
|
|
for (; !iterator.atEnd(); ++iterator) {
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
if (UNLIKELY(isTabOrNewline(*iterator))) {
|
|
|
|
syntaxViolation(hostBegin);
|
2016-09-06 18:16:07 +00:00
|
|
|
continue;
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
}
|
2016-09-06 18:16:07 +00:00
|
|
|
if (*iterator == ':')
|
|
|
|
break;
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
if (UNLIKELY(!isASCII(*iterator)))
|
|
|
|
syntaxViolation(hostBegin);
|
|
|
|
|
2016-09-06 18:16:07 +00:00
|
|
|
uint8_t buffer[U8_MAX_LENGTH];
|
|
|
|
int32_t offset = 0;
|
2020-10-05 14:40:55 +00:00
|
|
|
UBool isError = false;
|
|
|
|
U8_APPEND(buffer, offset, U8_MAX_LENGTH, *iterator, isError);
|
|
|
|
if (isError)
|
|
|
|
return false;
|
2016-09-06 18:16:07 +00:00
|
|
|
utf8Encoded.append(buffer, offset);
|
|
|
|
}
|
2018-04-30 21:17:59 +00:00
|
|
|
LCharBuffer percentDecoded = percentDecode(utf8Encoded.data(), utf8Encoded.size(), hostBegin);
|
2016-09-20 21:50:30 +00:00
|
|
|
String domain = String::fromUTF8(percentDecoded.data(), percentDecoded.size());
|
2017-01-23 23:26:55 +00:00
|
|
|
if (domain.isNull())
|
|
|
|
return false;
|
Hosts of URLs with non-special schemes should be case-sensitive, and non-ASCII characters in such hosts should be punycode-encoded
https://bugs.webkit.org/show_bug.cgi?id=163413
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/url-setters-expected.txt:
Update results. Some more tests are failing, but if my proposal in https://github.com/whatwg/url/issues/148 is accepted,
then these web platform tests will need to be changed. These web platform tests were also failing with the old URL::parse.
Source/WebCore:
This retains compatibility with the canonicalization Chrome, Firefox, and Safari with uppercase characters
in the hosts of URLs with unrecognized schemes. Safari treats such characters as the host, while Firefox
and Chrome treat such characters as part of the path, starting with the "//" after the ':'
Behavior of non-ASCII characters is inconsistent, and since we need to have a host, we should punycode-encode
the host to be consistent with special schemes because percent-encoding hosts sometimes is inconsistent.
This solution was proposed to the spec in https://github.com/whatwg/url/issues/148
Covered by updated API and layout tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::percentDecode):
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::hasInvalidDomainCharacter):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::formURLDecode):
(WebCore::percentDecode): Deleted.
(WebCore::domainToASCII): Deleted.
(WebCore::hasInvalidDomainCharacter): Deleted.
(WebCore::formURLDecode): Deleted.
* platform/URLParser.h:
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update parsing results. There are now fewer differences between the new URLParser and the old URL::parse.
LayoutTests:
* contentfiltering/block-after-add-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-add-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-allow-unblock-expected.txt:
* contentfiltering/block-after-finished-adding-data-then-deny-unblock-expected.txt:
* contentfiltering/block-after-response-then-allow-unblock-expected.txt:
* contentfiltering/block-after-response-then-deny-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-allow-unblock-expected.txt:
* contentfiltering/block-after-will-send-request-then-deny-unblock-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* fast/css/getComputedStyle/computed-style-border-image-expected.txt:
* fast/css/getComputedStyle/computed-style-border-image.html:
* fast/css/getComputedStyle/computed-style-cross-fade-expected.txt:
* fast/css/getComputedStyle/computed-style-cross-fade.html:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-background-shorthand.html:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-list-style-shorthand.html:
* fast/loader/url-parse-1-expected.txt:
* fast/url/host-lowercase-per-scheme-expected.txt:
* fast/url/safari-extension-expected.txt:
* http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt:
Update test expectations. This is how they were before r207162, showing that this change to the URLParser increases compatibility.
Canonical link: https://commits.webkit.org/181240@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-14 04:09:33 +00:00
|
|
|
if (domain != StringView(percentDecoded.data(), percentDecoded.size()))
|
|
|
|
syntaxViolation(hostBegin);
|
Reduce WTF::String operations that do unnecessary Unicode operations instead of ASCII
https://bugs.webkit.org/show_bug.cgi?id=179907
Reviewed by Sam Weinig.
Source/JavaScriptCore:
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::matches): Removed explicit TextCaseSensitive because RegularExpression now
defaults to that.
* runtime/StringPrototype.cpp:
(JSC::stringIncludesImpl): Use String::find since there is no overload of
String::contains that takes a start offset now that we removed the one that took a
caseSensitive boolean. We can add one later if we like, but this should do for now.
* yarr/RegularExpression.h: Moved the TextCaseSensitivity enumeration here from
the StringImpl.h header because it is only used here.
Source/WebCore:
* Modules/plugins/YouTubePluginReplacement.cpp:
(WebCore::hasCaseInsensitivePrefix): Deleted.
(WebCore::processAndCreateYouTubeURL): Use startsWithLettersIgnoringASCIICase.
* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::readHTTPHeaders): Use isAllASCII.
* accessibility/atk/AccessibilityObjectAtk.cpp:
(WebCore::AccessibilityObject::getLengthForTextRange const): Use text().length().
* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::traverseToOffsetInRange): Use isHTMLSpace instead of
isSpaceOrNewline since the code is trying to skip collapsible HTML spaces, not
arbitrary Unicode whitespace.
* accessibility/AccessibilityList.cpp:
(WebCore::AccessibilityList::childHasPseudoVisibleListItemMarkers): Use
isAllSpecialCharacters<isHTMLSpace> for the same reason as above.
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::isSearchField const): Use containsIgnoringASCIICase.
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::accessibilityObjectContainsText const): Use
new findPlainText function exported from TextIterator so this can share the
same search matching logic used to find text in webpages.
(WebCore::AccessibilityObject::selectText): Use capitalize and its return value
rather than makeCapitalize modifying a string in place.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::objectInclusionFromAltText): Use isAllSpecialCharacters<isHTMLSpace>
for the same reason as above.
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const): Ditto.
* bindings/js/JSDOMConvertStrings.cpp:
(WebCore::stringToByteString): Use isAllLatin1.
* contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::containsOnlyASCIIWithNoUppercase): Use
StringView::codeUnits instead of String::at.
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad const):
Use isAllASCII.
* contentextensions/URLFilterParser.cpp:
(WebCore::ContentExtensions::URLFilterParser::addPattern): Ditto.
* css/CSSFontFaceSrcValue.cpp:
(WebCore::CSSFontFaceSrcValue::isSupportedFormat const): Use protocolIs and
endsWithIgnoringASCIICase.
* css/DOMCSSNamespace.cpp:
(WebCore::valueWithoutImportant): Use endsWithIgnoringASCIICase.
* css/parser/CSSPropertyParser.cpp:
(WebCore::parseGridTemplateAreasRow): Use isAllSpecialCharacters<isCSSSpace>,
for the preflight, which matches what the actual parsing code uses.
* dom/CharacterData.cpp:
(WebCore::CharacterData::containsOnlyWhitespace const): Deleted. Callers can
efficiently get at the data and do this kind of check on the data directly.
* dom/CharacterData.h: Updated for the above.
* dom/DataTransfer.cpp:
(WebCore::normalizeType): Use startsWith since the string is already converted
to ASCII lowercase.
* dom/Position.cpp:
(WebCore::Position::leadingWhitespacePosition const): Use isHTMLSpace since
since the code is trying to check for collapsible HTML spaces, not general
Unicode spaces. Other call sites of isSpaceOrNewline need to be checked for
this, but I did not fix them all at this time.
(WebCore::Position::trailingWhitespacePosition const): Ditto.
* editing/Editor.cpp:
(WebCore::Editor::editorUIUpdateTimerFired): Use noBreakSpace.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::debugRenderer const): Use text().length() instead
of textLength.
(WebCore::FrameSelection::selectionAtWordStart const): Use noBreakSpace.
(WebCore::FrameSelection::wordSelectionContainingCaretSelection): Ditto.
(WebCore::FrameSelection::actualSelectionAtSentenceStart const): Ditto.
* editing/TextIterator.cpp:
(WebCore::textNodeOffsetInFlow): Use text().length().
(WebCore::TextIterator::handleTextNode): Ditto.
(WebCore::collapsedSpaceLength): Updated since RenderText::text now returns
a reference rather than a pointer.
(WebCore::findPlainText): Added. Uses SearchBuffer to search for one string
within another. Exported so accessibility code can do this operation.
* editing/TextIterator.h: Updated for the above.
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::markMisspellingsAfterTyping): Use noBreakSpace.
* editing/VisibleUnits.cpp:
(WebCore::findStartOfParagraph): Updated since RenderText::text now returns
a reference.
(WebCore::findEndOfParagraph): Ditto.
* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_processText): Use String::characterAt instead of String::at.
Use capitalize instead of makeCapitalized.
* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::stripMicrosoftPrefix): Use findIgnoringASCIICase.
* html/Autofill.cpp:
(WebCore::AutofillData::createFromHTMLFormControlElement): Use
startsWithLettersIgnoringASCIICase.
* html/BaseTextInputType.cpp:
(WebCore::BaseTextInputType::patternMismatch const): Removed explicit
TextCaseSensitive since it now is the default, and needed to touch this anyway
because the enumeration is now in a different namespace.
* html/EmailInputType.cpp:
(WebCore::isValidEmailAddress): Updated to use JSC::Yarr::TextCaseInsensitive.
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::hasFallbackContent const): Use
isAllSpecialCharacters<isHTMLSpace>.
(WebCore::HTMLObjectElement::shouldAllowQuickTimeClassIdQuirk): Use
startsWithLettersIgnoringASCIICase.
(WebCore::HTMLObjectElement::hasValidClassId): Use protocolIs.
(WebCore::preventsParentObjectFromExposure): Use isAllSpecialCharacters<isHTMLSpace>.
* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::setCompatibilityModeFromDoctype):
Use startsWithLettersIgnoringASCIICase.
* html/parser/HTMLMetaCharsetParser.cpp:
(WebCore::extractCharset): Use findIgnoringASCIICase.
* html/parser/XSSAuditor.cpp:
(WebCore::XSSAuditor::isContainedInRequest): Use containsIgnoringASCIICase.
* html/track/WebVTTParser.cpp:
(WebCore::WebVTTParser::hasRequiredFileIdentifier): Don't pass the length to
the String::startsWith function. There has never been a version of that function
that takes the length, there is no need to pass the length since the function
handles null-terminated strings like the one here, and in the past the length
has been getting converted to a boolean making the comparison be case sensitive.
Removing the argument entirely leaves it case sensitive.
* inspector/InspectorNodeFinder.cpp:
(WebCore::InspectorNodeFinder::matchesElement): Use startsWithIgnoringASCIICase
and endsWithIgnoringASCIICase.
* inspector/InspectorStyleSheet.cpp:
(WebCore::selectorsFromSource): Use JSC::Yarr::TextCaseSensitive.
* inspector/agents/InspectorDOMAgent.cpp:
(WebCore::containsOnlyHTMLWhitespace): Made this a non-member function
and reimplemented using isAllSpecialCharacters<isHTMLSpace>().
(WebCore::InspectorDOMAgent::innerFirstChild): Use containsOnlyHTMLWhitespace.
(WebCore::InspectorDOMAgent::innerNextSibling): Ditto.
(WebCore::InspectorDOMAgent::innerPreviousSibling): Ditto.
(WebCore::InspectorDOMAgent::innerChildNodeCount): Ditto.
(WebCore::InspectorDOMAgent::didInsertDOMNode): Ditto.
(WebCore::InspectorDOMAgent::didRemoveDOMNode): Ditto.
* inspector/agents/InspectorDOMAgent.h: Updated for above change.
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::shouldStoreResourceAsFlatFile):
Use startsWithLettersIgnoringASCIICase.
* page/Base64Utilities.cpp:
(WebCore::Base64Utilities::btoa): Use isAllLatin1.
* page/Frame.cpp:
(WebCore::createRegExpForLabels): Removed TextCaseSensitive argument since
that is now the default and also used JSC::Yarr::TextCaseInsensitive.
(WebCore::matchLabelsAgainstString): More of the same.
* page/FrameView.cpp:
(WebCore::countRenderedCharactersInRenderObjectWithThreshold): Use
text().length().
* page/SecurityOrigin.cpp:
(WebCore::isFeedWithNestedProtocolInHTTPFamily): Use
startsWithLettersIgnoringASCIICase.
* page/UserContentURLPattern.cpp:
(WebCore::UserContentURLPattern::matchesHost const):
Use endsWithIgnoringASCIICase.
* page/csp/ContentSecurityPolicySource.cpp:
(WebCore::ContentSecurityPolicySource::hostMatches const): Ditto.
* page/csp/ContentSecurityPolicySourceList.cpp:
(WebCore::ContentSecurityPolicySourceList::parseNonceSource):
Use startsWithIgnoringASCIICase.
* page/ios/FrameIOS.mm:
(WebCore::Frame::wordsInCurrentParagraph const): Use noBreakSpace.
* platform/ContentType.cpp:
(WebCore::ContentType::parameter const): Use findIgnoringASCIICase.
* platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::isSupportedFontMIMEType): Use
startsWithLettersIgnoringASCIICase.
(WebCore::MIMETypeRegistry::isSupportedJSONMIMEType): Use
mimeType.endsWithIgnoringASCIICase.
(WebCore::MIMETypeRegistry::isTextMIMEType): Use
startsWithLettersIgnoringASCIICase.
(WebCore::MIMETypeRegistry::isXMLMIMEType): Use endsWithIgnoringASCIICase.
(WebCore::MIMETypeRegistry::isJavaAppletMIMEType): Use
startsWithLettersIgnoringASCIICase.
(WebCore::MIMETypeRegistry::canShowMIMEType): Ditto.
* platform/URL.cpp:
(WebCore::isAllASCII): Renamed from containsOnlyASCII.
(WebCore::appendEncodedHostname): Use isAllASCII.
* platform/URLParser.cpp:
(WebCore::containsOnlyASCII): Deleted.
(WebCore::URLParser::domainToASCII): Use StringImpl::isAllASCII. Changed
to take StringImpl& to guarantee we won't keep doing null checks since
the caller already checks for null.
(WebCore::URLParser::parseHostAndPort): Pass StringImpl&.
* platform/URLParser.h: Updated for above.
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::supportsType): Use endsWithIgnoringASCIICase
and startsWithLettersIgnoringASCIICase.
* platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm:
(WebCore::validKeySystemRE): Use JSC::Yarr::TextCaseInsensitive.
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontCache::similarFont): Use containsIgnoringASCIICase for
the Geeza font special cases.
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::shouldRejectMIMEType): Use startsWithLettersIgnoringASCIICase.
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::getUnmangledInfoLog): Removed
TextCaseSensitive since it now is the default.
* platform/mac/PublicSuffixMac.mm:
(WebCore::topPrivatelyControlledDomain): Use isAllASCII.
* platform/mac/SSLKeyGeneratorMac.mm:
(WebCore::signedPublicKeyAndChallengeString): Use isAllASCII.
* platform/mac/StringUtilities.mm:
(WebCore::stringMatchesWildcardString): Use JSC::Yarr::TextCaseInsensitive.
* platform/mediastream/RealtimeMediaSourceCenter.cpp:
(WebCore::addStringToSHA1): Use isAllASCII.
* platform/network/CacheValidation.cpp:
(WebCore::parseCacheControlDirectives): Use containsIgnoringASCIICase.
* platform/network/HTTPParsers.cpp:
(WebCore::parseHTTPRefresh): Use findIgnoringASCIICase.
(WebCore::findCharsetInMediaType): Ditto.
(WebCore::parseRange): Use startsWithLettersIgnoringASCIICase.
* platform/network/curl/AuthenticationChallengeCurl.cpp:
(WebCore::AuthenticationChallenge::protectionSpaceFromHandle):
Use findIgnoringASCIICase.
* platform/network/curl/MultipartHandle.cpp:
(WebCore::MultipartHandle::extractBoundary): Ditto.
* platform/network/curl/ResourceHandleCurlDelegate.cpp:
(WebCore::ResourceHandleCurlDelegate::handleDataURL): Use
endsWithIgnoringASCIICase.
* platform/network/curl/ResourceResponseCurl.cpp:
(WebCore::ResourceResponse::isAppendableHeader): Use
startsWithLettersIgnoringASCIICase.
(WebCore::ResourceResponse::appendHTTPHeaderField): Ditto.
* platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::extractMarkupFromCFHTML): Use findIgnoringASCIICase.
(WebCore::fragmentFromCFHTML): Ditto.
* rendering/BidiRun.cpp:
(WebCore::BidiRun::BidiRun): Use text().length().
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::absolutePDFURL const): Use
endsWithIgnoringASCIICase.
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::placeBoxRangeInInlineDirection): Use text().length().
* rendering/InlineIterator.h:
(WebCore::InlineIterator::fastIncrementInTextNode): Ditto.
(WebCore::InlineIterator::increment): Dtto.
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::isLineBreak const): Updated since RenderText::text
now returns a StringImpl&.
(WebCore::InlineTextBox::selectionStartEnd const): Use text().length().
(WebCore::InlineTextBox::text const): Updated since RenderText::text
now returns a StringImpl&.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::constructTextRun): Use text().length().
* rendering/RenderBlockFlow.cpp:
(WebCore::isVisibleRenderText): Use isAllSpecialCharacters<isHTMLSpace>().
(WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths const):
Use the new trimmedPreferredWidths that returns a structure instead of the
old one with lots of arguments. Also use text().length().
* rendering/RenderBlockLineLayout.cpp:
(WebCore::endsWithHTMLSpaces): Renamed and changed to use isHTMLSpace
instead of isASCIISpace.
(WebCore::reachedEndOfTextRenderer): Use endsWithHTMLSpaces.
(WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
Updated for hcanges to RenderText.
(WebCore::RenderBlockFlow::handleTrailingSpaces): Ditto.
(WebCore::RenderBlockFlow::determineStartPosition): Ditto.
* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::combineTextIfNeeded): Use
isAllSpecialCharacters<isHTMLSpace>.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects const): Ditto.
* rendering/RenderListBox.cpp:
(WebCore::bolder): Added. Helper function.
(WebCore::RenderListBox::updateFromElement): Rewrote to
only compute the bolder font once rather than for every item.
(WebCore::RenderListBox::paintItemForeground): Updated for
change to applyTextTransform.
* rendering/RenderMenuList.cpp:
(WebCore::RenderMenuList::adjustInnerStyle): Updated for change
to RenderText::text.
(RenderMenuList::updateOptionsWidth): Updated for change to
applyTextTransform.
(RenderMenuList::itemText const): Ditto.
* rendering/RenderText.cpp:
(WebCore::capitalize): Renamed from makeCapitalized. Changed to
take and return a String instead of taking a String*.
(WebCore::RenderText::RenderText): Use isAllASCII. Also moved
initialization of most non-bitfield members to the class definition.
(WebCore::RenderText::positionForPoint): Use text().
(WebCore::RenderText::widthFromCache const): Ditto.
(WebCore::RenderText::hangablePunctuationStartWidth const): Ditto.
(WebCore::RenderText::hangablePunctuationEndWidth const): Ditto.
(WebCore::RenderText::isHangableStopOrComma): Ditto.
(WebCore::RenderText::firstCharacterIndexStrippingSpaces const): Ditto.
(WebCore::RenderText::lastCharacterIndexStrippingSpaces const): Ditto.
(WebCore::RenderText::trimmedPreferredWidths): Changed to return values
in a structure instead of taking lots of arguments.
(WebCore::RenderText::computePreferredLogicalWidths): Updated to use
the text() function.
(WebCore::isAllCollapsibleWhitespace): Added.
(WebCore::RenderText::isAllCollapsibleWhitespace const): Updated to
use a tighter loop.
(WebCore::isAllPossiblyCollapsibleWhitespace): Added.
(WebCore::RenderText::containsOnlyHTMLWhitespace const): Updated to
use a tighter loop. Renamed from containsOnlyWhitespace.
(WebCore::RenderText::setTextWithOffset): Updated to use text().
(WebCore::isInlineFlowOrEmptyText): Rewrote to be easier to read.
(WebCore::RenderText::previousCharacter const): Got rid of unneeded
null check and simplified.
(WebCore::applyTextTransform): Changed to return a String rather
than modifying one that is passed in.
(WebCore::RenderText::setRenderedText): Updated use of applyTextTransform.
(WebCore::RenderText::secureText): More of the same.
(WebCore::RenderText::computeCanUseSimplifiedTextMeasuring const): Ditto.
(WebCore::RenderText::textWithoutConvertingBackslashToYenSymbol const): Ditto.
(WebCore::RenderText::width const): Ditto.
(WebCore::RenderText::collectSelectionRectsForLineBoxes): Ditto.
(WebCore::RenderText::previousOffset const): Ditto.
(WebCore::RenderText::previousOffsetForBackwardDeletion const): Ditto.
(WebCore::RenderText::nextOffset const): Ditto.
(WebCore::RenderText::computeCanUseSimpleFontCodePath const): Ditto.
(WebCore::RenderText::stringView const): Ditto.
* rendering/RenderText.h: Made some more members private and final.
Updated for above, including adding the Widths structure. Got rid of the
textLength function, which existed as a workaround before we could mark
a function like length final. Made the text function return a StringImpl&,
which is good since the m_text string is never null, and so callers end
up using StringImpl directly and saving null checks. Removed functions
that are not needed, including is8Bit, characters8, characters16,
uncheckedCharacterAt, operator[], and isAllASCII.
* rendering/RenderTextFragment.cpp:
(WebCore::RenderTextFragment::setText): Use text().length().
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::caretMaxOffset const): Ditto.
(WebCore::RenderTextLineBoxes::positionForPoint const): Ditto.
(WebCore::RenderTextLineBoxes::setSelectionState): Ditto.
(WebCore::RenderTextLineBoxes::absoluteQuads const): Ditto.
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseForFontAndText): Ditto.
* rendering/SimpleLineLayoutCoverage.cpp:
(WebCore::SimpleLineLayout::textLengthForSubtree): Ditto.
(WebCore::SimpleLineLayout::collectNonEmptyLeafRenderBlockFlows): Ditto.
* rendering/SimpleLineLayoutFlowContents.cpp:
(WebCore::SimpleLineLayout::initializeSegments): Ditto.
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::textOffsetForPoint): Ditto.
* rendering/SimpleLineLayoutFunctions.h:
(WebCore::SimpleLineLayout::findCaretMaximumOffset): Ditto.
* rendering/line/BreakingContext.h:
(WebCore::shouldAddBorderPaddingMargin): Ditto.
(WebCore::shouldSkipWhitespaceAfterStartObject): Ditto.
(WebCore::iteratorIsBeyondEndOfRenderCombineText): Ditto.
(WebCore::textWidth): Ditto.
(WebCore::BreakingContext::handleText): Ditto.
(WebCore::BreakingContext::optimalLineBreakLocationForTrailingWord): Ditto.
* rendering/line/TrailingObjects.cpp:
(WebCore::TrailingObjects::updateWhitespaceCollapsingTransitionsForTrailingBoxes): Ditto.
* rendering/mathml/RenderMathMLFenced.cpp:
(WebCore::RenderMathMLFenced::updateFromElement): Removed stray use of "unsigned int".
* rendering/svg/RenderSVGInlineText.cpp:
(WebCore::RenderSVGInlineText::characterStartsNewTextChunk const): Use text().length().
(WebCore::RenderSVGInlineText::positionForPoint): Ditto.
* rendering/svg/SVGTextLayoutAttributesBuilder.cpp:
(WebCore::processRenderSVGInlineText): Ditto.
* rendering/svg/SVGTextLayoutEngine.cpp:
(WebCore::SVGTextLayoutEngine::currentLogicalCharacterAttributes): Ditto.
* rendering/svg/SVGTextQuery.cpp:
(WebCore::SVGTextQuery::modifyStartEndPositionsRespectingLigatures const): Ditto.
* style/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::updateRenderTree): Use isAllSpecialCharacters<isHTMLSpace>.
(WebCore::RenderTreeUpdater::textRendererIsNeeded): Ditto.
* svg/SVGTests.cpp:
(WebCore::SVGTests::hasFeatureForLegacyBindings): Use startsWithLettersIgnoringASCIICase.
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::shouldAllowExternalLoad): Ditto.
Source/WebKit:
* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::isMediaMIMEType): Use startsWithLettersIgnoringASCIICase.
* NetworkProcess/cache/NetworkCacheKey.cpp:
(WebKit::NetworkCache::hashString): Use isAllASCII..
* UIProcess/API/C/WKWebsitePolicies.cpp:
(WKWebsitePoliciesSetCustomHeaderFields): Use startsWithLettersIgnoringASCIICase..
* UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
(-[_WKWebsitePolicies setCustomHeaderFields:]): Ditto.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::savePDFToFileInDownloadsFolder): Use endsWithIgnoringASCIICase.
* UIProcess/WebPreferences.cpp:
(WebKit::WebPreferences::WebPreferences): Initialize m_identifier explicitly. Somehow
changing the String default constructor to be "= default" led to a warning that we
otherwise did not get about not initializing m_identifier. Arguably a compiler bug,
but legitimately strange that the copy constructor does not copy m_identifier and so
nice to be explicit about it, I guess.
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplicationRaw): Use
endsWithIgnoringASCIICase.
(WebKit::WebPageProxy::openPDFFromTemporaryFolderWithNativeApplication): Ditto.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::createPlugin): Ditto.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::platformEditorState const): Use isAllSpecialCharacters<isHTMLSpace>.
Source/WebKitLegacy/mac:
* History/BinaryPropertyList.cpp:
(BinaryPropertyListPlan::writeStringObject): Use isAllASCII.
(BinaryPropertyListSerializer::appendStringObject): Ditto.
* WebView/WebHTMLRepresentation.mm:
(regExpForLabels): Removed TextCaseSensitive since it is now the default.
(matchLabelsAgainstString): Use JSC::Yarr::TextCaseInsensitive.
Source/WebKitLegacy/win:
* Plugins/PluginDatabaseWin.cpp:
(WebCore::PluginDatabase::getPluginPathsInDirectories const): Use
startsWithLettersIgnoringASCIICase and endsWithIgnoringASCIICase.
* WebDownloadCFNet.cpp:
(WebDownload::initToResumeWithBundle): Use endsWithIgnoringASCIICase.
* WebView.cpp:
(WebView::markAllMatchesForText): Fix old code that was passing TextCaseSensitivity
to a function that actually takes FindOptions. By luck, TextCaseSensitive happens to
be 0, which is correct FindOptions for case sensitive matching, and TextCaseInsensitive
happens to be 1, which is correct FindOptions for case insensitive matching, so fixing
the code does not cause any change in behavior.
Source/WTF:
* wtf/text/ASCIIFastPath.h: Moved the using for charactersAreAllASCII here since
the function is defined here.
* wtf/text/AtomicString.h: Removed overloads of contains, find, startsWith, and
endsWith that take a boolean indicating whether they should be "case sensitive".
When false, this was doing Unicode case folding, and no callers needed that.
Also tweaked formatting and argument names.
* wtf/text/IntegerToStringConversion.h: Added an include of LChar.h since this file
uses that. Also tweaked formatting a bit.
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::containsOnlyWhitespace): Deleted. Despite its name sounding like
it used the full Unicode whitespace definition, this actually checked isASCIISpace.
Callers now all use isAllSpecialCharacters instead with the whitespace definition
that is appropriate to each call site.
(WTF::latin1CaseFoldTable): Deleted.
(WTF::equalCompatibilityCaseless): Deleted.
(WTF::StringImpl::findIgnoringCase): Deleted.
(WTF::findIgnoringCaseInner): Deleted.
(WTF::reverseFindIgnoringCaseInner): Deleted.
(WTF::StringImpl::reverseFindIgnoringCase): Deleted.
(WTF::equalInner): Removed boolean caseSensitive argument.
(WTF::StringImpl::startsWith): Ditto.
(WTF::StringImpl::endsWith): Ditto.
* wtf/text/StringImpl.h: Moved TextCaseSensitivity out into a different header.
Moved ASCIIFastPath.h include here from WTFString.h. Moved isAllSpecialCharacters
free function here from WTFString.h. Moved lots of function bodies out of class
definitions to make the class definitions easier to read. Sorted things a bit.
Tweaked formatting. Marked constructor that takes one argument explicit. Added
an isEmpty function like the one in String. Renamed copyChars to copyCharacters.
Added isAllASCII, isAllLatin1 and isAllSpecialCharacters functions. Removed
boolean caseSensitive arguments from various functions. Removed findIgnoringCase
and reverseFindIgnoringCase. Added a FIXME to codePointCompare about the way it
treats null and empty strings as equal. Changed length argument in remove to
unsigned to match other lengths.
* wtf/text/WTFString.cpp:
(WTF::String::removeInternal): Changed length argument to be unsigned.
(WTF::createWithFormatAndArguments): Use emptyString.
(WTF::String::isSafeToSendToAnotherThread const): Rewrote to be easier to read.
* wtf/text/WTFString.h: Moved ASCIIFastPath.h to StringImpl.h. Moved lots of
function bodies out of class definitions to make the class definitions easier
to read, made others one-liners. Removed the String::at function but kept the
String::characterAt function; the two were identical. Removed boolean
caseSensitive arguments from various functions. Removed findIgnoringCase and
reverseFindIgnoringCase. Renamed containsOnlyASCII to isAllASCII and
containsOnlyLatin1 to isAllLatin1 to match the naming of isAllSpecialCharacters.
Moved the inline implementations of functions that are defined above further
down, after things like the ASCIILiteral class and various functions.
* wtf/text/icu/UTextProviderLatin1.cpp: Updated name of copyChars.
Tools:
* DumpRenderTree/mac/DumpRenderTree.mm:
(changeWindowScaleIfNeeded): Use containsIgnoringASCIICase.
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::urlContains const): Ditto.
Canonical link: https://commits.webkit.org/195985@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225117 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-23 17:32:42 +00:00
|
|
|
auto asciiDomain = domainToASCII(*domain.impl(), hostBegin);
|
2017-02-13 22:52:34 +00:00
|
|
|
if (!asciiDomain || hasForbiddenHostCodePoint(asciiDomain.value()))
|
2016-09-06 18:16:07 +00:00
|
|
|
return false;
|
2018-04-30 21:17:59 +00:00
|
|
|
LCharBuffer& asciiDomainValue = asciiDomain.value();
|
2016-09-20 21:50:30 +00:00
|
|
|
const LChar* asciiDomainCharacters = asciiDomainValue.data();
|
2016-09-16 20:35:16 +00:00
|
|
|
|
2017-02-14 07:43:28 +00:00
|
|
|
auto address = parseIPv4Host(hostBegin, CodePointIterator<LChar>(asciiDomainValue.begin(), asciiDomainValue.end()));
|
|
|
|
if (address) {
|
2016-09-23 23:40:46 +00:00
|
|
|
serializeIPv4(address.value());
|
|
|
|
m_url.m_hostEnd = currentPosition(iterator);
|
2016-09-15 18:12:09 +00:00
|
|
|
if (iterator.atEnd()) {
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-09-08 22:28:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-09-23 19:57:57 +00:00
|
|
|
return parsePort(iterator);
|
2016-08-22 05:42:12 +00:00
|
|
|
}
|
2017-02-14 07:43:28 +00:00
|
|
|
if (address.error() == IPv4ParsingError::Failure)
|
|
|
|
return false;
|
2016-09-16 20:35:16 +00:00
|
|
|
|
2016-09-23 22:32:28 +00:00
|
|
|
appendToASCIIBuffer(asciiDomainCharacters, asciiDomainValue.size());
|
2016-09-23 23:40:46 +00:00
|
|
|
m_url.m_hostEnd = currentPosition(iterator);
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
if (!iterator.atEnd())
|
2016-09-23 19:57:57 +00:00
|
|
|
return parsePort(iterator);
|
2018-07-13 00:28:36 +00:00
|
|
|
m_url.m_portLength = 0;
|
2016-09-03 00:32:49 +00:00
|
|
|
return true;
|
2016-08-11 19:09:39 +00:00
|
|
|
}
|
2016-08-12 23:12:46 +00:00
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<String> URLParser::formURLDecode(StringView input)
|
2016-09-14 01:34:27 +00:00
|
|
|
{
|
|
|
|
auto utf8 = input.utf8(StrictConversion);
|
|
|
|
if (utf8.isNull())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2021-06-08 17:35:15 +00:00
|
|
|
auto percentDecoded = percentDecode(utf8.dataAsUInt8Ptr(), utf8.length());
|
2020-08-24 22:36:02 +00:00
|
|
|
return String::fromUTF8ReplacingInvalidSequences(percentDecoded.data(), percentDecoded.size());
|
2016-09-14 01:34:27 +00:00
|
|
|
}
|
|
|
|
|
2017-04-28 20:43:26 +00:00
|
|
|
// https://url.spec.whatwg.org/#concept-urlencoded-parser
|
2016-09-14 01:34:27 +00:00
|
|
|
auto URLParser::parseURLEncodedForm(StringView input) -> URLEncodedForm
|
|
|
|
{
|
|
|
|
URLEncodedForm output;
|
2017-01-24 17:44:50 +00:00
|
|
|
for (StringView bytes : input.split('&')) {
|
2017-04-28 20:43:26 +00:00
|
|
|
auto equalIndex = bytes.find('=');
|
|
|
|
if (equalIndex == notFound) {
|
|
|
|
auto name = formURLDecode(bytes.toString().replace('+', 0x20));
|
|
|
|
if (name)
|
|
|
|
output.append({ name.value(), emptyString() });
|
2016-09-14 01:34:27 +00:00
|
|
|
} else {
|
2017-04-28 20:43:26 +00:00
|
|
|
auto name = formURLDecode(bytes.substring(0, equalIndex).toString().replace('+', 0x20));
|
|
|
|
auto value = formURLDecode(bytes.substring(equalIndex + 1).toString().replace('+', 0x20));
|
2016-09-14 01:34:27 +00:00
|
|
|
if (name && value)
|
2017-04-28 20:43:26 +00:00
|
|
|
output.append({ name.value(), value.value() });
|
2016-09-14 01:34:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2018-05-04 00:40:18 +00:00
|
|
|
static void serializeURLEncodedForm(const String& input, Vector<LChar>& output)
|
2016-09-14 01:34:27 +00:00
|
|
|
{
|
|
|
|
auto utf8 = input.utf8(StrictConversion);
|
|
|
|
const char* data = utf8.data();
|
|
|
|
for (size_t i = 0; i < utf8.length(); ++i) {
|
|
|
|
const char byte = data[i];
|
|
|
|
if (byte == 0x20)
|
|
|
|
output.append(0x2B);
|
|
|
|
else if (byte == 0x2A
|
|
|
|
|| byte == 0x2D
|
|
|
|
|| byte == 0x2E
|
|
|
|
|| (byte >= 0x30 && byte <= 0x39)
|
|
|
|
|| (byte >= 0x41 && byte <= 0x5A)
|
|
|
|
|| byte == 0x5F
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
|| (byte >= 0x61 && byte <= 0x7A)) // FIXME: Put these in the characterClassTable to avoid branches.
|
2016-09-14 01:34:27 +00:00
|
|
|
output.append(byte);
|
|
|
|
else
|
2016-09-21 06:34:13 +00:00
|
|
|
percentEncodeByte(byte, output);
|
2016-09-14 01:34:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String URLParser::serialize(const URLEncodedForm& tuples)
|
|
|
|
{
|
2017-07-13 18:21:48 +00:00
|
|
|
if (tuples.isEmpty())
|
|
|
|
return { };
|
|
|
|
|
2018-05-04 00:40:18 +00:00
|
|
|
Vector<LChar> output;
|
2016-09-14 01:34:27 +00:00
|
|
|
for (auto& tuple : tuples) {
|
|
|
|
if (!output.isEmpty())
|
|
|
|
output.append('&');
|
2017-01-20 01:35:58 +00:00
|
|
|
serializeURLEncodedForm(tuple.key, output);
|
2016-09-14 01:34:27 +00:00
|
|
|
output.append('=');
|
2017-01-20 01:35:58 +00:00
|
|
|
serializeURLEncodedForm(tuple.value, output);
|
2016-09-14 01:34:27 +00:00
|
|
|
}
|
2016-09-21 03:10:57 +00:00
|
|
|
return String::adopt(WTFMove(output));
|
2016-09-14 01:34:27 +00:00
|
|
|
}
|
|
|
|
|
Support IDN2008 with UTS #46 instead of IDN2003
https://bugs.webkit.org/show_bug.cgi?id=144194
Reviewed by Darin Adler.
Source/WebCore:
Use uidna_nameToASCII instead of the deprecated uidna_IDNToASCII.
It uses IDN2008 instead of IDN2003, and it uses UTF #46 when used with a UIDNA opened with uidna_openUTS46.
This follows https://url.spec.whatwg.org/#concept-domain-to-ascii except we do not use Transitional_Processing
to prevent homograph attacks on german domain names with "ß" and "ss" in them. These are now treated as separate domains.
Firefox also doesn't use Transitional_Processing. Chrome and the current specification use Transitional_processing,
but https://github.com/whatwg/url/issues/110 might change the spec.
In addition, http://unicode.org/reports/tr46/ says:
"implementations are encouraged to apply the Bidi and ContextJ validity criteria"
Bidi checks prevent domain names with bidirectional text, such as latin and hebrew characters in the same domain. Chrome and Firefox do this.
ContextJ checks prevent code points such as U+200D, which is a zero-width joiner which users would not see when looking at the domain name.
Firefox currently enables ContextJ checks and it is suggested by UTS #46, so we'll do it.
ContextO checks, which we do not use and neither does any other browser nor the spec, would fail if a domain contains code points such as U+30FB,
which looks somewhat like a dot. We can investigate enabling these checks later.
Covered by new API tests and rebased LayoutTests.
The new API tests verify that we do not use transitional processing, that we do apply the Bidi and ContextJ checks, but not ContextO checks.
* platform/URLParser.cpp:
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::internationalDomainNameTranscoder):
* platform/URLParser.h:
* platform/mac/WebCoreNSURLExtras.mm:
(WebCore::mapHostNameWithRange):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Add some tests from http://unicode.org/faq/idn.html verifying that we follow UTS46's deviations from IDN2008.
Add some tests based on https://tools.ietf.org/html/rfc5893 verifying that we check for bidirectional text.
Add a test based on https://tools.ietf.org/html/rfc5892 verifying that we do not do ContextO check.
Add a test for U+321D and U+321E which have particularly interesting punycode encodings. We match Firefox here now.
Also add a test from http://www.unicode.org/reports/tr46/#IDNAComparison verifying we are not using IDN2003.
We should consider importing all of http://www.unicode.org/Public/idna/9.0.0/IdnaTest.txt as URL domain tests.
LayoutTests:
* fast/encoding/idn-security.html:
Move some characters with changed IDN encodings to inside the check for old ICU.
* fast/url/idna2003-expected.txt:
* fast/url/idna2008-expected.txt:
Update expected results. We are now more compliant with IDN2008.
Canonical link: https://commits.webkit.org/182613@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208902 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-18 22:47:24 +00:00
|
|
|
const UIDNA& URLParser::internationalDomainNameTranscoder()
|
|
|
|
{
|
|
|
|
static UIDNA* encoder;
|
|
|
|
static std::once_flag onceFlag;
|
|
|
|
std::call_once(onceFlag, [] {
|
|
|
|
UErrorCode error = U_ZERO_ERROR;
|
|
|
|
encoder = uidna_openUTS46(UIDNA_CHECK_BIDI | UIDNA_CHECK_CONTEXTJ | UIDNA_NONTRANSITIONAL_TO_UNICODE | UIDNA_NONTRANSITIONAL_TO_ASCII, &error);
|
2020-12-15 02:58:56 +00:00
|
|
|
if (UNLIKELY(U_FAILURE(error)))
|
|
|
|
CRASH_WITH_INFO(error);
|
Support IDN2008 with UTS #46 instead of IDN2003
https://bugs.webkit.org/show_bug.cgi?id=144194
Reviewed by Darin Adler.
Source/WebCore:
Use uidna_nameToASCII instead of the deprecated uidna_IDNToASCII.
It uses IDN2008 instead of IDN2003, and it uses UTF #46 when used with a UIDNA opened with uidna_openUTS46.
This follows https://url.spec.whatwg.org/#concept-domain-to-ascii except we do not use Transitional_Processing
to prevent homograph attacks on german domain names with "ß" and "ss" in them. These are now treated as separate domains.
Firefox also doesn't use Transitional_Processing. Chrome and the current specification use Transitional_processing,
but https://github.com/whatwg/url/issues/110 might change the spec.
In addition, http://unicode.org/reports/tr46/ says:
"implementations are encouraged to apply the Bidi and ContextJ validity criteria"
Bidi checks prevent domain names with bidirectional text, such as latin and hebrew characters in the same domain. Chrome and Firefox do this.
ContextJ checks prevent code points such as U+200D, which is a zero-width joiner which users would not see when looking at the domain name.
Firefox currently enables ContextJ checks and it is suggested by UTS #46, so we'll do it.
ContextO checks, which we do not use and neither does any other browser nor the spec, would fail if a domain contains code points such as U+30FB,
which looks somewhat like a dot. We can investigate enabling these checks later.
Covered by new API tests and rebased LayoutTests.
The new API tests verify that we do not use transitional processing, that we do apply the Bidi and ContextJ checks, but not ContextO checks.
* platform/URLParser.cpp:
(WebCore::URLParser::domainToASCII):
(WebCore::URLParser::internationalDomainNameTranscoder):
* platform/URLParser.h:
* platform/mac/WebCoreNSURLExtras.mm:
(WebCore::mapHostNameWithRange):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Add some tests from http://unicode.org/faq/idn.html verifying that we follow UTS46's deviations from IDN2008.
Add some tests based on https://tools.ietf.org/html/rfc5893 verifying that we check for bidirectional text.
Add a test based on https://tools.ietf.org/html/rfc5892 verifying that we do not do ContextO check.
Add a test for U+321D and U+321E which have particularly interesting punycode encodings. We match Firefox here now.
Also add a test from http://www.unicode.org/reports/tr46/#IDNAComparison verifying we are not using IDN2003.
We should consider importing all of http://www.unicode.org/Public/idna/9.0.0/IdnaTest.txt as URL domain tests.
LayoutTests:
* fast/encoding/idn-security.html:
Move some characters with changed IDN encodings to inside the check for old ICU.
* fast/url/idna2003-expected.txt:
* fast/url/idna2008-expected.txt:
Update expected results. We are now more compliant with IDN2008.
Canonical link: https://commits.webkit.org/182613@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208902 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-18 22:47:24 +00:00
|
|
|
RELEASE_ASSERT(encoder);
|
|
|
|
});
|
|
|
|
return *encoder;
|
|
|
|
}
|
|
|
|
|
2016-08-12 23:12:46 +00:00
|
|
|
bool URLParser::allValuesEqual(const URL& a, const URL& b)
|
|
|
|
{
|
2018-07-13 00:28:36 +00:00
|
|
|
URL_PARSER_LOG("%d %d %d %d %d %d %d %d %d %d %d %d %s\n%d %d %d %d %d %d %d %d %d %d %d %d %s",
|
2016-08-17 00:41:30 +00:00
|
|
|
a.m_isValid,
|
2018-07-13 00:28:36 +00:00
|
|
|
a.m_cannotBeABaseURL,
|
2016-08-17 00:41:30 +00:00
|
|
|
a.m_protocolIsInHTTPFamily,
|
|
|
|
a.m_schemeEnd,
|
|
|
|
a.m_userStart,
|
|
|
|
a.m_userEnd,
|
|
|
|
a.m_passwordEnd,
|
|
|
|
a.m_hostEnd,
|
2018-07-13 00:28:36 +00:00
|
|
|
a.m_hostEnd + a.m_portLength,
|
2016-08-17 00:41:30 +00:00
|
|
|
a.m_pathAfterLastSlash,
|
|
|
|
a.m_pathEnd,
|
|
|
|
a.m_queryEnd,
|
|
|
|
a.m_string.utf8().data(),
|
|
|
|
b.m_isValid,
|
2018-07-13 00:28:36 +00:00
|
|
|
b.m_cannotBeABaseURL,
|
2016-08-17 00:41:30 +00:00
|
|
|
b.m_protocolIsInHTTPFamily,
|
|
|
|
b.m_schemeEnd,
|
|
|
|
b.m_userStart,
|
|
|
|
b.m_userEnd,
|
|
|
|
b.m_passwordEnd,
|
|
|
|
b.m_hostEnd,
|
2018-07-13 00:28:36 +00:00
|
|
|
b.m_hostEnd + b.m_portLength,
|
2016-08-17 00:41:30 +00:00
|
|
|
b.m_pathAfterLastSlash,
|
|
|
|
b.m_pathEnd,
|
|
|
|
b.m_queryEnd,
|
|
|
|
b.m_string.utf8().data());
|
|
|
|
|
2016-08-12 23:12:46 +00:00
|
|
|
return a.m_string == b.m_string
|
|
|
|
&& a.m_isValid == b.m_isValid
|
2018-07-13 00:28:36 +00:00
|
|
|
&& a.m_cannotBeABaseURL == b.m_cannotBeABaseURL
|
2016-08-12 23:12:46 +00:00
|
|
|
&& a.m_protocolIsInHTTPFamily == b.m_protocolIsInHTTPFamily
|
|
|
|
&& a.m_schemeEnd == b.m_schemeEnd
|
|
|
|
&& a.m_userStart == b.m_userStart
|
|
|
|
&& a.m_userEnd == b.m_userEnd
|
|
|
|
&& a.m_passwordEnd == b.m_passwordEnd
|
|
|
|
&& a.m_hostEnd == b.m_hostEnd
|
2018-07-13 00:28:36 +00:00
|
|
|
&& a.m_portLength == b.m_portLength
|
2016-08-12 23:12:46 +00:00
|
|
|
&& a.m_pathAfterLastSlash == b.m_pathAfterLastSlash
|
|
|
|
&& a.m_pathEnd == b.m_pathEnd
|
2017-07-11 17:02:14 +00:00
|
|
|
&& a.m_queryEnd == b.m_queryEnd;
|
2016-08-12 23:12:46 +00:00
|
|
|
}
|
|
|
|
|
2016-09-20 18:46:26 +00:00
|
|
|
bool URLParser::internalValuesConsistent(const URL& url)
|
Implement URLParser::syntaxViolation
https://bugs.webkit.org/show_bug.cgi?id=162593
Reviewed by Geoffrey Garen.
Source/WebCore:
Most of the time when parsing URLs, we just look at the URL, find offsets of the host, path, query, etc.,
and the String can be used untouched. When this happens, we do not want to allocate and copy the String.
We want to just add a reference to an existing String.
Sometimes we need to canonicalize the String because there has been a syntaxViolation,
defined as any String that is different than its canonicalized URL String. In such cases we need to
allocate a new String and fill it with the canonicalized URL String. When a syntaxViolation happens for the
first time, we know that everything in the input String up to that point is equal to what it would have been
if we had canonicalized the beginning of the URL, copy it into a buffer, and continue parsing in a mode where
instead of just looking at the input URL String, we canonicalize each code point into the buffer.
Changes to behavior involve additional spec compliance with tabs and newlines in different places in URLs,
as well as additional spec compliance when parsing empty and null URLs relative to other URLs.
Both are covered by new API tests. Existing behavior covered by existing API tests.
This is about a 15% speed improvement on my URL parsing benchmark.
* platform/URL.cpp:
(WebCore::assertProtocolIsGood):
(WebCore::URL::protocolIs):
(WebCore::protocolIs):
* platform/URL.h:
* platform/URLParser.cpp:
(WebCore::isTabOrNewline):
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
(WebCore::URLParser::isWindowsDriveLetter):
(WebCore::URLParser::appendToASCIIBuffer):
(WebCore::URLParser::checkWindowsDriveLetter):
(WebCore::URLParser::shouldCopyFileURL):
(WebCore::URLParser::utf8PercentEncode):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::syntaxViolation):
(WebCore::URLParser::fragmentSyntaxViolation):
(WebCore::URLParser::parsedDataView):
(WebCore::URLParser::currentPosition):
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseIPv6Host):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::serializeURLEncodedForm):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):
(WebCore::URLParser::incrementIteratorSkippingTabAndNewLine): Deleted.
(WebCore::URLParser::syntaxError): Deleted.
(WebCore::parseIPv4Number): Deleted.
* platform/URLParser.h:
(WebCore::URLParser::incrementIteratorSkippingTabsAndNewlines):
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/180569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-27 20:07:15 +00:00
|
|
|
{
|
2016-09-20 18:46:26 +00:00
|
|
|
return url.m_schemeEnd <= url.m_userStart
|
|
|
|
&& url.m_userStart <= url.m_userEnd
|
|
|
|
&& url.m_userEnd <= url.m_passwordEnd
|
|
|
|
&& url.m_passwordEnd <= url.m_hostEnd
|
2018-07-13 00:28:36 +00:00
|
|
|
&& url.m_hostEnd + url.m_portLength <= url.m_pathAfterLastSlash
|
2016-09-20 18:46:26 +00:00
|
|
|
&& url.m_pathAfterLastSlash <= url.m_pathEnd
|
|
|
|
&& url.m_pathEnd <= url.m_queryEnd
|
2017-07-11 17:02:14 +00:00
|
|
|
&& url.m_queryEnd <= url.m_string.length();
|
2016-09-20 18:46:26 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 03:28:36 +00:00
|
|
|
} // namespace WTF
|