| 1 | /* |
| 2 | * Copyright (C) 2016 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | #include "WTFStringUtilities.h" |
| 28 | #include <wtf/MainThread.h> |
| 29 | #include <wtf/URLParser.h> |
| 30 | #include <wtf/text/StringBuilder.h> |
| 31 | |
| 32 | namespace TestWebKitAPI { |
| 33 | |
| 34 | class WTF_URLParser : public testing::Test { |
| 35 | public: |
| 36 | void SetUp() final |
| 37 | { |
| 38 | WTF::initializeMainThread(); |
| 39 | } |
| 40 | }; |
| 41 | |
| 42 | struct ExpectedParts { |
| 43 | String protocol; |
| 44 | String user; |
| 45 | String password; |
| 46 | String host; |
| 47 | unsigned short port; |
| 48 | String path; |
| 49 | String query; |
| 50 | String fragment; |
| 51 | String string; |
| 52 | |
| 53 | bool isInvalid() const |
| 54 | { |
| 55 | return protocol.isEmpty() |
| 56 | && user.isEmpty() |
| 57 | && password.isEmpty() |
| 58 | && host.isEmpty() |
| 59 | && !port |
| 60 | && path.isEmpty() |
| 61 | && query.isEmpty() |
| 62 | && fragment.isEmpty(); |
| 63 | } |
| 64 | }; |
| 65 | |
| 66 | template<typename T, typename U> |
| 67 | bool eq(T&& s1, U&& s2) |
| 68 | { |
| 69 | EXPECT_STREQ(s1.utf8().data(), s2.utf8().data()); |
| 70 | return s1.utf8() == s2.utf8(); |
| 71 | } |
| 72 | |
| 73 | static String insertTabAtLocation(const String& string, size_t location) |
| 74 | { |
| 75 | ASSERT(location <= string.length()); |
| 76 | return makeString(string.substring(0, location), "\t" , string.substring(location)); |
| 77 | } |
| 78 | |
| 79 | static ExpectedParts invalidParts(const String& urlStringWithTab) |
| 80 | { |
| 81 | return {"" , "" , "" , "" , 0, "" , "" , "" , urlStringWithTab}; |
| 82 | } |
| 83 | |
| 84 | enum class TestTabs { No, Yes }; |
| 85 | |
| 86 | // Inserting tabs between surrogate pairs changes the encoded value instead of being skipped by the URLParser. |
| 87 | const TestTabs testTabsValueForSurrogatePairs = TestTabs::No; |
| 88 | |
| 89 | static void checkURL(const String& urlString, const ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes) |
| 90 | { |
| 91 | auto url = URL(URL(), urlString); |
| 92 | |
| 93 | EXPECT_TRUE(eq(parts.protocol, url.protocol())); |
| 94 | EXPECT_TRUE(eq(parts.user, url.user())); |
| 95 | EXPECT_TRUE(eq(parts.password, url.pass())); |
| 96 | EXPECT_TRUE(eq(parts.host, url.host())); |
| 97 | EXPECT_EQ(parts.port, url.port().valueOr(0)); |
| 98 | EXPECT_TRUE(eq(parts.path, url.path())); |
| 99 | EXPECT_TRUE(eq(parts.query, url.query())); |
| 100 | EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier())); |
| 101 | EXPECT_TRUE(eq(parts.string, url.string())); |
| 102 | |
| 103 | EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); |
| 104 | |
| 105 | if (testTabs == TestTabs::No) |
| 106 | return; |
| 107 | |
| 108 | for (size_t i = 0; i < urlString.length(); ++i) { |
| 109 | String urlStringWithTab = insertTabAtLocation(urlString, i); |
| 110 | checkURL(urlStringWithTab, |
| 111 | parts.isInvalid() ? invalidParts(urlStringWithTab) : parts, |
| 112 | TestTabs::No); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | static void checkRelativeURL(const String& urlString, const String& baseURLString, const ExpectedParts& parts, TestTabs testTabs = TestTabs::Yes) |
| 117 | { |
| 118 | auto url = URL(URL(URL(), baseURLString), urlString); |
| 119 | |
| 120 | EXPECT_TRUE(eq(parts.protocol, url.protocol())); |
| 121 | EXPECT_TRUE(eq(parts.user, url.user())); |
| 122 | EXPECT_TRUE(eq(parts.password, url.pass())); |
| 123 | EXPECT_TRUE(eq(parts.host, url.host())); |
| 124 | EXPECT_EQ(parts.port, url.port().valueOr(0)); |
| 125 | EXPECT_TRUE(eq(parts.path, url.path())); |
| 126 | EXPECT_TRUE(eq(parts.query, url.query())); |
| 127 | EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier())); |
| 128 | EXPECT_TRUE(eq(parts.string, url.string())); |
| 129 | |
| 130 | EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); |
| 131 | |
| 132 | if (testTabs == TestTabs::No) |
| 133 | return; |
| 134 | |
| 135 | for (size_t i = 0; i < urlString.length(); ++i) { |
| 136 | String urlStringWithTab = insertTabAtLocation(urlString, i); |
| 137 | checkRelativeURL(urlStringWithTab, |
| 138 | baseURLString, |
| 139 | parts.isInvalid() ? invalidParts(urlStringWithTab) : parts, |
| 140 | TestTabs::No); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | static void checkURLDifferences(const String& urlString, const ExpectedParts& partsNew, const ExpectedParts& partsOld, TestTabs testTabs = TestTabs::Yes) |
| 145 | { |
| 146 | UNUSED_PARAM(partsOld); // FIXME: Remove all the old expected parts. |
| 147 | auto url = URL(URL(), urlString); |
| 148 | |
| 149 | EXPECT_TRUE(eq(partsNew.protocol, url.protocol())); |
| 150 | EXPECT_TRUE(eq(partsNew.user, url.user())); |
| 151 | EXPECT_TRUE(eq(partsNew.password, url.pass())); |
| 152 | EXPECT_TRUE(eq(partsNew.host, url.host())); |
| 153 | EXPECT_EQ(partsNew.port, url.port().valueOr(0)); |
| 154 | EXPECT_TRUE(eq(partsNew.path, url.path())); |
| 155 | EXPECT_TRUE(eq(partsNew.query, url.query())); |
| 156 | EXPECT_TRUE(eq(partsNew.fragment, url.fragmentIdentifier())); |
| 157 | EXPECT_TRUE(eq(partsNew.string, url.string())); |
| 158 | |
| 159 | EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); |
| 160 | |
| 161 | if (testTabs == TestTabs::No) |
| 162 | return; |
| 163 | |
| 164 | for (size_t i = 0; i < urlString.length(); ++i) { |
| 165 | String urlStringWithTab = insertTabAtLocation(urlString, i); |
| 166 | checkURLDifferences(urlStringWithTab, |
| 167 | partsNew.isInvalid() ? invalidParts(urlStringWithTab) : partsNew, |
| 168 | partsOld.isInvalid() ? invalidParts(urlStringWithTab) : partsOld, |
| 169 | TestTabs::No); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | static void checkRelativeURLDifferences(const String& urlString, const String& baseURLString, const ExpectedParts& partsNew, const ExpectedParts& partsOld, TestTabs testTabs = TestTabs::Yes) |
| 174 | { |
| 175 | UNUSED_PARAM(partsOld); // FIXME: Remove all the old expected parts. |
| 176 | auto url = URL(URL(URL(), baseURLString), urlString); |
| 177 | |
| 178 | EXPECT_TRUE(eq(partsNew.protocol, url.protocol())); |
| 179 | EXPECT_TRUE(eq(partsNew.user, url.user())); |
| 180 | EXPECT_TRUE(eq(partsNew.password, url.pass())); |
| 181 | EXPECT_TRUE(eq(partsNew.host, url.host())); |
| 182 | EXPECT_EQ(partsNew.port, url.port().valueOr(0)); |
| 183 | EXPECT_TRUE(eq(partsNew.path, url.path())); |
| 184 | EXPECT_TRUE(eq(partsNew.query, url.query())); |
| 185 | EXPECT_TRUE(eq(partsNew.fragment, url.fragmentIdentifier())); |
| 186 | EXPECT_TRUE(eq(partsNew.string, url.string())); |
| 187 | |
| 188 | EXPECT_TRUE(WTF::URLParser::internalValuesConsistent(url)); |
| 189 | |
| 190 | if (testTabs == TestTabs::No) |
| 191 | return; |
| 192 | |
| 193 | for (size_t i = 0; i < urlString.length(); ++i) { |
| 194 | String urlStringWithTab = insertTabAtLocation(urlString, i); |
| 195 | checkRelativeURLDifferences(urlStringWithTab, baseURLString, |
| 196 | partsNew.isInvalid() ? invalidParts(urlStringWithTab) : partsNew, |
| 197 | partsOld.isInvalid() ? invalidParts(urlStringWithTab) : partsOld, |
| 198 | TestTabs::No); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | static void shouldFail(const String& urlString) |
| 203 | { |
| 204 | checkURL(urlString, {"" , "" , "" , "" , 0, "" , "" , "" , urlString}); |
| 205 | } |
| 206 | |
| 207 | static void shouldFail(const String& urlString, const String& baseString) |
| 208 | { |
| 209 | checkRelativeURL(urlString, baseString, {"" , "" , "" , "" , 0, "" , "" , "" , urlString}); |
| 210 | } |
| 211 | |
| 212 | TEST_F(WTF_URLParser, Basic) |
| 213 | { |
| 214 | checkURL("http://user:pass@webkit.org:123/path?query#fragment" , {"http" , "user" , "pass" , "webkit.org" , 123, "/path" , "query" , "fragment" , "http://user:pass@webkit.org:123/path?query#fragment" }); |
| 215 | checkURL("http://user:pass@webkit.org:123/path?query" , {"http" , "user" , "pass" , "webkit.org" , 123, "/path" , "query" , "" , "http://user:pass@webkit.org:123/path?query" }); |
| 216 | checkURL("http://user:pass@webkit.org:123/path" , {"http" , "user" , "pass" , "webkit.org" , 123, "/path" , "" , "" , "http://user:pass@webkit.org:123/path" }); |
| 217 | checkURL("http://user:pass@webkit.org:123/" , {"http" , "user" , "pass" , "webkit.org" , 123, "/" , "" , "" , "http://user:pass@webkit.org:123/" }); |
| 218 | checkURL("http://user:pass@webkit.org:123" , {"http" , "user" , "pass" , "webkit.org" , 123, "/" , "" , "" , "http://user:pass@webkit.org:123/" }); |
| 219 | checkURL("http://user:pass@webkit.org" , {"http" , "user" , "pass" , "webkit.org" , 0, "/" , "" , "" , "http://user:pass@webkit.org/" }); |
| 220 | checkURL("http://user:\t\t\tpass@webkit.org" , {"http" , "user" , "pass" , "webkit.org" , 0, "/" , "" , "" , "http://user:pass@webkit.org/" }); |
| 221 | checkURL("http://us\ter:pass@webkit.org" , {"http" , "user" , "pass" , "webkit.org" , 0, "/" , "" , "" , "http://user:pass@webkit.org/" }); |
| 222 | checkURL("http://user:pa\tss@webkit.org" , {"http" , "user" , "pass" , "webkit.org" , 0, "/" , "" , "" , "http://user:pass@webkit.org/" }); |
| 223 | checkURL("http://user:pass\t@webkit.org" , {"http" , "user" , "pass" , "webkit.org" , 0, "/" , "" , "" , "http://user:pass@webkit.org/" }); |
| 224 | checkURL("http://\tuser:pass@webkit.org" , {"http" , "user" , "pass" , "webkit.org" , 0, "/" , "" , "" , "http://user:pass@webkit.org/" }); |
| 225 | checkURL("http://user\t:pass@webkit.org" , {"http" , "user" , "pass" , "webkit.org" , 0, "/" , "" , "" , "http://user:pass@webkit.org/" }); |
| 226 | checkURL("http://webkit.org" , {"http" , "" , "" , "webkit.org" , 0, "/" , "" , "" , "http://webkit.org/" }); |
| 227 | checkURL("http://127.0.0.1" , {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1/" }); |
| 228 | checkURL("http://webkit.org/" , {"http" , "" , "" , "webkit.org" , 0, "/" , "" , "" , "http://webkit.org/" }); |
| 229 | checkURL("http://webkit.org/path1/path2/index.html" , {"http" , "" , "" , "webkit.org" , 0, "/path1/path2/index.html" , "" , "" , "http://webkit.org/path1/path2/index.html" }); |
| 230 | checkURL("about:blank" , {"about" , "" , "" , "" , 0, "blank" , "" , "" , "about:blank" }); |
| 231 | checkURL("about:blank?query" , {"about" , "" , "" , "" , 0, "blank" , "query" , "" , "about:blank?query" }); |
| 232 | checkURL("about:blank#fragment" , {"about" , "" , "" , "" , 0, "blank" , "" , "fragment" , "about:blank#fragment" }); |
| 233 | checkURL("http://[0:f::f:f:0:0]" , {"http" , "" , "" , "[0:f::f:f:0:0]" , 0, "/" , "" , "" , "http://[0:f::f:f:0:0]/" }); |
| 234 | checkURL("http://[0:f:0:0:f::]" , {"http" , "" , "" , "[0:f:0:0:f::]" , 0, "/" , "" , "" , "http://[0:f:0:0:f::]/" }); |
| 235 | checkURL("http://[::f:0:0:f:0:0]" , {"http" , "" , "" , "[::f:0:0:f:0:0]" , 0, "/" , "" , "" , "http://[::f:0:0:f:0:0]/" }); |
| 236 | checkURL("http://[0:f:0:0:f::]:" , {"http" , "" , "" , "[0:f:0:0:f::]" , 0, "/" , "" , "" , "http://[0:f:0:0:f::]/" }); |
| 237 | checkURL("http://[0:f:0:0:f::]:\t" , {"http" , "" , "" , "[0:f:0:0:f::]" , 0, "/" , "" , "" , "http://[0:f:0:0:f::]/" }); |
| 238 | checkURL("http://[0:f:0:0:f::]\t:" , {"http" , "" , "" , "[0:f:0:0:f::]" , 0, "/" , "" , "" , "http://[0:f:0:0:f::]/" }); |
| 239 | checkURL("http://\t[::f:0:0:f:0:0]" , {"http" , "" , "" , "[::f:0:0:f:0:0]" , 0, "/" , "" , "" , "http://[::f:0:0:f:0:0]/" }); |
| 240 | checkURL("http://[\t::f:0:0:f:0:0]" , {"http" , "" , "" , "[::f:0:0:f:0:0]" , 0, "/" , "" , "" , "http://[::f:0:0:f:0:0]/" }); |
| 241 | checkURL("http://[:\t:f:0:0:f:0:0]" , {"http" , "" , "" , "[::f:0:0:f:0:0]" , 0, "/" , "" , "" , "http://[::f:0:0:f:0:0]/" }); |
| 242 | checkURL("http://[::\tf:0:0:f:0:0]" , {"http" , "" , "" , "[::f:0:0:f:0:0]" , 0, "/" , "" , "" , "http://[::f:0:0:f:0:0]/" }); |
| 243 | checkURL("http://[::f\t:0:0:f:0:0]" , {"http" , "" , "" , "[::f:0:0:f:0:0]" , 0, "/" , "" , "" , "http://[::f:0:0:f:0:0]/" }); |
| 244 | checkURL("http://[::f:\t0:0:f:0:0]" , {"http" , "" , "" , "[::f:0:0:f:0:0]" , 0, "/" , "" , "" , "http://[::f:0:0:f:0:0]/" }); |
| 245 | checkURL("http://example.com/path1/path2/." , {"http" , "" , "" , "example.com" , 0, "/path1/path2/" , "" , "" , "http://example.com/path1/path2/" }); |
| 246 | checkURL("http://example.com/path1/path2/.." , {"http" , "" , "" , "example.com" , 0, "/path1/" , "" , "" , "http://example.com/path1/" }); |
| 247 | checkURL("http://example.com/path1/path2/./path3" , {"http" , "" , "" , "example.com" , 0, "/path1/path2/path3" , "" , "" , "http://example.com/path1/path2/path3" }); |
| 248 | checkURL("http://example.com/path1/path2/.\\path3" , {"http" , "" , "" , "example.com" , 0, "/path1/path2/path3" , "" , "" , "http://example.com/path1/path2/path3" }); |
| 249 | checkURL("http://example.com/path1/path2/../path3" , {"http" , "" , "" , "example.com" , 0, "/path1/path3" , "" , "" , "http://example.com/path1/path3" }); |
| 250 | checkURL("http://example.com/path1/path2/..\\path3" , {"http" , "" , "" , "example.com" , 0, "/path1/path3" , "" , "" , "http://example.com/path1/path3" }); |
| 251 | checkURL("http://example.com/." , {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }); |
| 252 | checkURL("http://example.com/.." , {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }); |
| 253 | checkURL("http://example.com/./path1" , {"http" , "" , "" , "example.com" , 0, "/path1" , "" , "" , "http://example.com/path1" }); |
| 254 | checkURL("http://example.com/../path1" , {"http" , "" , "" , "example.com" , 0, "/path1" , "" , "" , "http://example.com/path1" }); |
| 255 | checkURL("http://example.com/../path1/../../path2/path3/../path4" , {"http" , "" , "" , "example.com" , 0, "/path2/path4" , "" , "" , "http://example.com/path2/path4" }); |
| 256 | checkURL("http://example.com/path1/.%2" , {"http" , "" , "" , "example.com" , 0, "/path1/.%2" , "" , "" , "http://example.com/path1/.%2" }); |
| 257 | checkURL("http://example.com/path1/%2" , {"http" , "" , "" , "example.com" , 0, "/path1/%2" , "" , "" , "http://example.com/path1/%2" }); |
| 258 | checkURL("http://example.com/path1/%" , {"http" , "" , "" , "example.com" , 0, "/path1/%" , "" , "" , "http://example.com/path1/%" }); |
| 259 | checkURL("http://example.com/path1/.%" , {"http" , "" , "" , "example.com" , 0, "/path1/.%" , "" , "" , "http://example.com/path1/.%" }); |
| 260 | checkURL("http://example.com//." , {"http" , "" , "" , "example.com" , 0, "//" , "" , "" , "http://example.com//" }); |
| 261 | checkURL("http://example.com//./" , {"http" , "" , "" , "example.com" , 0, "//" , "" , "" , "http://example.com//" }); |
| 262 | checkURL("http://example.com//.//" , {"http" , "" , "" , "example.com" , 0, "///" , "" , "" , "http://example.com///" }); |
| 263 | checkURL("http://example.com//.." , {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }); |
| 264 | checkURL("http://example.com//../" , {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }); |
| 265 | checkURL("http://example.com//..//" , {"http" , "" , "" , "example.com" , 0, "//" , "" , "" , "http://example.com//" }); |
| 266 | checkURL("http://example.com//.." , {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }); |
| 267 | checkURL("http://example.com/.//" , {"http" , "" , "" , "example.com" , 0, "//" , "" , "" , "http://example.com//" }); |
| 268 | checkURL("http://example.com/..//" , {"http" , "" , "" , "example.com" , 0, "//" , "" , "" , "http://example.com//" }); |
| 269 | checkURL("http://example.com/./" , {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }); |
| 270 | checkURL("http://example.com/../" , {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }); |
| 271 | checkURL("http://example.com/path1/.../path3" , {"http" , "" , "" , "example.com" , 0, "/path1/.../path3" , "" , "" , "http://example.com/path1/.../path3" }); |
| 272 | checkURL("http://example.com/path1/..." , {"http" , "" , "" , "example.com" , 0, "/path1/..." , "" , "" , "http://example.com/path1/..." }); |
| 273 | checkURL("http://example.com/path1/.../" , {"http" , "" , "" , "example.com" , 0, "/path1/.../" , "" , "" , "http://example.com/path1/.../" }); |
| 274 | checkURL("http://example.com/.path1/" , {"http" , "" , "" , "example.com" , 0, "/.path1/" , "" , "" , "http://example.com/.path1/" }); |
| 275 | checkURL("http://example.com/..path1/" , {"http" , "" , "" , "example.com" , 0, "/..path1/" , "" , "" , "http://example.com/..path1/" }); |
| 276 | checkURL("http://example.com/path1/.path2" , {"http" , "" , "" , "example.com" , 0, "/path1/.path2" , "" , "" , "http://example.com/path1/.path2" }); |
| 277 | checkURL("http://example.com/path1/..path2" , {"http" , "" , "" , "example.com" , 0, "/path1/..path2" , "" , "" , "http://example.com/path1/..path2" }); |
| 278 | checkURL("http://example.com/path1/path2/.?query" , {"http" , "" , "" , "example.com" , 0, "/path1/path2/" , "query" , "" , "http://example.com/path1/path2/?query" }); |
| 279 | checkURL("http://example.com/path1/path2/..?query" , {"http" , "" , "" , "example.com" , 0, "/path1/" , "query" , "" , "http://example.com/path1/?query" }); |
| 280 | checkURL("http://example.com/path1/path2/.#fragment" , {"http" , "" , "" , "example.com" , 0, "/path1/path2/" , "" , "fragment" , "http://example.com/path1/path2/#fragment" }); |
| 281 | checkURL("http://example.com/path1/path2/..#fragment" , {"http" , "" , "" , "example.com" , 0, "/path1/" , "" , "fragment" , "http://example.com/path1/#fragment" }); |
| 282 | |
| 283 | checkURL("file:" , {"file" , "" , "" , "" , 0, "/" , "" , "" , "file:///" }); |
| 284 | checkURL("file:/" , {"file" , "" , "" , "" , 0, "/" , "" , "" , "file:///" }); |
| 285 | checkURL("file://" , {"file" , "" , "" , "" , 0, "/" , "" , "" , "file:///" }); |
| 286 | checkURL("file:///" , {"file" , "" , "" , "" , 0, "/" , "" , "" , "file:///" }); |
| 287 | checkURL("file:////" , {"file" , "" , "" , "" , 0, "//" , "" , "" , "file:////" }); // This matches Firefox and URL::parse which I believe are correct, but not Chrome. |
| 288 | checkURL("file:/path" , {"file" , "" , "" , "" , 0, "/path" , "" , "" , "file:///path" }); |
| 289 | checkURL("file://host/path" , {"file" , "" , "" , "host" , 0, "/path" , "" , "" , "file://host/path" }); |
| 290 | checkURL("file://host" , {"file" , "" , "" , "host" , 0, "/" , "" , "" , "file://host/" }); |
| 291 | checkURL("file://host/" , {"file" , "" , "" , "host" , 0, "/" , "" , "" , "file://host/" }); |
| 292 | checkURL("file:///path" , {"file" , "" , "" , "" , 0, "/path" , "" , "" , "file:///path" }); |
| 293 | checkURL("file:////path" , {"file" , "" , "" , "" , 0, "//path" , "" , "" , "file:////path" }); |
| 294 | checkURL("file://localhost/path" , {"file" , "" , "" , "" , 0, "/path" , "" , "" , "file:///path" }); |
| 295 | checkURL("file://localhost/" , {"file" , "" , "" , "" , 0, "/" , "" , "" , "file:///" }); |
| 296 | checkURL("file://localhost" , {"file" , "" , "" , "" , 0, "/" , "" , "" , "file:///" }); |
| 297 | checkURL("file://lOcAlHoSt" , {"file" , "" , "" , "" , 0, "/" , "" , "" , "file:///" }); |
| 298 | checkURL("file://lOcAlHoSt/" , {"file" , "" , "" , "" , 0, "/" , "" , "" , "file:///" }); |
| 299 | checkURL("file:/pAtH/" , {"file" , "" , "" , "" , 0, "/pAtH/" , "" , "" , "file:///pAtH/" }); |
| 300 | checkURL("file:/pAtH" , {"file" , "" , "" , "" , 0, "/pAtH" , "" , "" , "file:///pAtH" }); |
| 301 | checkURL("file:?query" , {"file" , "" , "" , "" , 0, "/" , "query" , "" , "file:///?query" }); |
| 302 | checkURL("file:#fragment" , {"file" , "" , "" , "" , 0, "/" , "" , "fragment" , "file:///#fragment" }); |
| 303 | checkURL("file:?query#fragment" , {"file" , "" , "" , "" , 0, "/" , "query" , "fragment" , "file:///?query#fragment" }); |
| 304 | checkURL("file:#fragment?notquery" , {"file" , "" , "" , "" , 0, "/" , "" , "fragment?notquery" , "file:///#fragment?notquery" }); |
| 305 | checkURL("file:/?query" , {"file" , "" , "" , "" , 0, "/" , "query" , "" , "file:///?query" }); |
| 306 | checkURL("file:/#fragment" , {"file" , "" , "" , "" , 0, "/" , "" , "fragment" , "file:///#fragment" }); |
| 307 | checkURL("file://?query" , {"file" , "" , "" , "" , 0, "/" , "query" , "" , "file:///?query" }); |
| 308 | checkURL("file://#fragment" , {"file" , "" , "" , "" , 0, "/" , "" , "fragment" , "file:///#fragment" }); |
| 309 | checkURL("file:///?query" , {"file" , "" , "" , "" , 0, "/" , "query" , "" , "file:///?query" }); |
| 310 | checkURL("file:///#fragment" , {"file" , "" , "" , "" , 0, "/" , "" , "fragment" , "file:///#fragment" }); |
| 311 | checkURL("file:////?query" , {"file" , "" , "" , "" , 0, "//" , "query" , "" , "file:////?query" }); |
| 312 | checkURL("file:////#fragment" , {"file" , "" , "" , "" , 0, "//" , "" , "fragment" , "file:////#fragment" }); |
| 313 | checkURL("file://?Q" , {"file" , "" , "" , "" , 0, "/" , "Q" , "" , "file:///?Q" }); |
| 314 | checkURL("file://#F" , {"file" , "" , "" , "" , 0, "/" , "" , "F" , "file:///#F" }); |
| 315 | checkURL("file://host?Q" , {"file" , "" , "" , "host" , 0, "/" , "Q" , "" , "file://host/?Q" }); |
| 316 | checkURL("file://host#F" , {"file" , "" , "" , "host" , 0, "/" , "" , "F" , "file://host/#F" }); |
| 317 | checkURL("file://host\\P" , {"file" , "" , "" , "host" , 0, "/P" , "" , "" , "file://host/P" }); |
| 318 | checkURL("file://host\\?Q" , {"file" , "" , "" , "host" , 0, "/" , "Q" , "" , "file://host/?Q" }); |
| 319 | checkURL("file://host\\../P" , {"file" , "" , "" , "host" , 0, "/P" , "" , "" , "file://host/P" }); |
| 320 | checkURL("file://host\\/../P" , {"file" , "" , "" , "host" , 0, "/P" , "" , "" , "file://host/P" }); |
| 321 | checkURL("file://host\\/P" , {"file" , "" , "" , "host" , 0, "//P" , "" , "" , "file://host//P" }); |
| 322 | checkURL("http://host/A b" , {"http" , "" , "" , "host" , 0, "/A%20b" , "" , "" , "http://host/A%20b" }); |
| 323 | checkURL("http://host/a%20B" , {"http" , "" , "" , "host" , 0, "/a%20B" , "" , "" , "http://host/a%20B" }); |
| 324 | checkURL("http://host?q=@ <>!#fragment" , {"http" , "" , "" , "host" , 0, "/" , "q=@%20%3C%3E!" , "fragment" , "http://host/?q=@%20%3C%3E!#fragment" }); |
| 325 | checkURL("http://user:@host" , {"http" , "user" , "" , "host" , 0, "/" , "" , "" , "http://user@host/" }); |
| 326 | checkURL("http://user:@\thost" , {"http" , "user" , "" , "host" , 0, "/" , "" , "" , "http://user@host/" }); |
| 327 | checkURL("http://user:\t@host" , {"http" , "user" , "" , "host" , 0, "/" , "" , "" , "http://user@host/" }); |
| 328 | checkURL("http://user\t:@host" , {"http" , "user" , "" , "host" , 0, "/" , "" , "" , "http://user@host/" }); |
| 329 | checkURL("http://use\tr:@host" , {"http" , "user" , "" , "host" , 0, "/" , "" , "" , "http://user@host/" }); |
| 330 | checkURL("http://127.0.0.1:10100/path" , {"http" , "" , "" , "127.0.0.1" , 10100, "/path" , "" , "" , "http://127.0.0.1:10100/path" }); |
| 331 | checkURL("http://127.0.0.1:/path" , {"http" , "" , "" , "127.0.0.1" , 0, "/path" , "" , "" , "http://127.0.0.1/path" }); |
| 332 | checkURL("http://127.0.0.1\t:/path" , {"http" , "" , "" , "127.0.0.1" , 0, "/path" , "" , "" , "http://127.0.0.1/path" }); |
| 333 | checkURL("http://127.0.0.1:\t/path" , {"http" , "" , "" , "127.0.0.1" , 0, "/path" , "" , "" , "http://127.0.0.1/path" }); |
| 334 | checkURL("http://127.0.0.1:/\tpath" , {"http" , "" , "" , "127.0.0.1" , 0, "/path" , "" , "" , "http://127.0.0.1/path" }); |
| 335 | checkURL("http://127.0.0.1:123" , {"http" , "" , "" , "127.0.0.1" , 123, "/" , "" , "" , "http://127.0.0.1:123/" }); |
| 336 | checkURL("http://127.0.0.1:" , {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1/" }); |
| 337 | checkURL("http://[0:f::f:f:0:0]:123/path" , {"http" , "" , "" , "[0:f::f:f:0:0]" , 123, "/path" , "" , "" , "http://[0:f::f:f:0:0]:123/path" }); |
| 338 | checkURL("http://[0:f::f:f:0:0]:123" , {"http" , "" , "" , "[0:f::f:f:0:0]" , 123, "/" , "" , "" , "http://[0:f::f:f:0:0]:123/" }); |
| 339 | checkURL("http://[0:f:0:0:f:\t:]:123" , {"http" , "" , "" , "[0:f:0:0:f::]" , 123, "/" , "" , "" , "http://[0:f:0:0:f::]:123/" }); |
| 340 | checkURL("http://[0:f:0:0:f::\t]:123" , {"http" , "" , "" , "[0:f:0:0:f::]" , 123, "/" , "" , "" , "http://[0:f:0:0:f::]:123/" }); |
| 341 | checkURL("http://[0:f:0:0:f::]\t:123" , {"http" , "" , "" , "[0:f:0:0:f::]" , 123, "/" , "" , "" , "http://[0:f:0:0:f::]:123/" }); |
| 342 | checkURL("http://[0:f:0:0:f::]:\t123" , {"http" , "" , "" , "[0:f:0:0:f::]" , 123, "/" , "" , "" , "http://[0:f:0:0:f::]:123/" }); |
| 343 | checkURL("http://[0:f:0:0:f::]:1\t23" , {"http" , "" , "" , "[0:f:0:0:f::]" , 123, "/" , "" , "" , "http://[0:f:0:0:f::]:123/" }); |
| 344 | checkURL("http://[0:f::f:f:0:0]:/path" , {"http" , "" , "" , "[0:f::f:f:0:0]" , 0, "/path" , "" , "" , "http://[0:f::f:f:0:0]/path" }); |
| 345 | checkURL("http://[0:f::f:f:0:0]:" , {"http" , "" , "" , "[0:f::f:f:0:0]" , 0, "/" , "" , "" , "http://[0:f::f:f:0:0]/" }); |
| 346 | checkURL("http://host:10100/path" , {"http" , "" , "" , "host" , 10100, "/path" , "" , "" , "http://host:10100/path" }); |
| 347 | checkURL("http://host:/path" , {"http" , "" , "" , "host" , 0, "/path" , "" , "" , "http://host/path" }); |
| 348 | checkURL("http://host:123" , {"http" , "" , "" , "host" , 123, "/" , "" , "" , "http://host:123/" }); |
| 349 | checkURL("http://host:" , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 350 | checkURL("http://hos\tt\n:\t1\n2\t3\t/\npath" , {"http" , "" , "" , "host" , 123, "/path" , "" , "" , "http://host:123/path" }); |
| 351 | checkURL("http://user@example.org/path3" , {"http" , "user" , "" , "example.org" , 0, "/path3" , "" , "" , "http://user@example.org/path3" }); |
| 352 | checkURL("sc:/pa/pa" , {"sc" , "" , "" , "" , 0, "/pa/pa" , "" , "" , "sc:/pa/pa" }); |
| 353 | checkURL("sc:/pa" , {"sc" , "" , "" , "" , 0, "/pa" , "" , "" , "sc:/pa" }); |
| 354 | checkURL("sc:/pa/" , {"sc" , "" , "" , "" , 0, "/pa/" , "" , "" , "sc:/pa/" }); |
| 355 | checkURL("notspecial:/notuser:notpassword@nothost" , {"notspecial" , "" , "" , "" , 0, "/notuser:notpassword@nothost" , "" , "" , "notspecial:/notuser:notpassword@nothost" }); |
| 356 | checkURL("sc://pa/" , {"sc" , "" , "" , "pa" , 0, "/" , "" , "" , "sc://pa/" }); |
| 357 | checkURL("sc://\tpa/" , {"sc" , "" , "" , "pa" , 0, "/" , "" , "" , "sc://pa/" }); |
| 358 | checkURL("sc:/\t/pa/" , {"sc" , "" , "" , "pa" , 0, "/" , "" , "" , "sc://pa/" }); |
| 359 | checkURL("sc:\t//pa/" , {"sc" , "" , "" , "pa" , 0, "/" , "" , "" , "sc://pa/" }); |
| 360 | checkURL("http://host \a " , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 361 | checkURL("notspecial:/a" , {"notspecial" , "" , "" , "" , 0, "/a" , "" , "" , "notspecial:/a" }); |
| 362 | checkURL("notspecial:" , {"notspecial" , "" , "" , "" , 0, "" , "" , "" , "notspecial:" }); |
| 363 | checkURL("http:/a" , {"http" , "" , "" , "a" , 0, "/" , "" , "" , "http://a/" }); |
| 364 | checkURL("http://256../" , {"http" , "" , "" , "256.." , 0, "/" , "" , "" , "http://256../" }); |
| 365 | checkURL("http://256.." , {"http" , "" , "" , "256.." , 0, "/" , "" , "" , "http://256../" }); |
| 366 | checkURL("http://127..1/" , {"http" , "" , "" , "127..1" , 0, "/" , "" , "" , "http://127..1/" }); |
| 367 | checkURL("http://127.a.0.1/" , {"http" , "" , "" , "127.a.0.1" , 0, "/" , "" , "" , "http://127.a.0.1/" }); |
| 368 | checkURL("http://127.0.0.1/" , {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1/" }); |
| 369 | checkURL("http://12\t7.0.0.1/" , {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1/" }); |
| 370 | checkURL("http://127.\t0.0.1/" , {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1/" }); |
| 371 | checkURL("http://./" , {"http" , "" , "" , "." , 0, "/" , "" , "" , "http://./" }); |
| 372 | checkURL("http://." , {"http" , "" , "" , "." , 0, "/" , "" , "" , "http://./" }); |
| 373 | checkURL("notspecial:/a" , {"notspecial" , "" , "" , "" , 0, "/a" , "" , "" , "notspecial:/a" }); |
| 374 | checkURL("notspecial:" , {"notspecial" , "" , "" , "" , 0, "" , "" , "" , "notspecial:" }); |
| 375 | checkURL("notspecial:/" , {"notspecial" , "" , "" , "" , 0, "/" , "" , "" , "notspecial:/" }); |
| 376 | checkURL("data:image/png;base64,encoded-data-follows-here" , {"data" , "" , "" , "" , 0, "image/png;base64,encoded-data-follows-here" , "" , "" , "data:image/png;base64,encoded-data-follows-here" }); |
| 377 | checkURL("data:image/png;base64,encoded/data-with-slash" , {"data" , "" , "" , "" , 0, "image/png;base64,encoded/data-with-slash" , "" , "" , "data:image/png;base64,encoded/data-with-slash" }); |
| 378 | checkURL("about:~" , {"about" , "" , "" , "" , 0, "~" , "" , "" , "about:~" }); |
| 379 | checkURL("https://@test@test@example:800\\path@end" , {"" , "" , "" , "" , 0, "" , "" , "" , "https://@test@test@example:800\\path@end" }); |
| 380 | checkURL("http://www.example.com/#a\nb\rc\td" , {"http" , "" , "" , "www.example.com" , 0, "/" , "" , "abcd" , "http://www.example.com/#abcd" }); |
| 381 | checkURL("http://[A:b:c:DE:fF:0:1:aC]/" , {"http" , "" , "" , "[a:b:c:de:ff:0:1:ac]" , 0, "/" , "" , "" , "http://[a:b:c:de:ff:0:1:ac]/" }); |
| 382 | checkURL("http:////////user:@webkit.org:99?foo" , {"http" , "user" , "" , "webkit.org" , 99, "/" , "foo" , "" , "http://user@webkit.org:99/?foo" }); |
| 383 | checkURL("http:////////user:@webkit.org:99#foo" , {"http" , "user" , "" , "webkit.org" , 99, "/" , "" , "foo" , "http://user@webkit.org:99/#foo" }); |
| 384 | checkURL("http:////\t////user:@webkit.org:99?foo" , {"http" , "user" , "" , "webkit.org" , 99, "/" , "foo" , "" , "http://user@webkit.org:99/?foo" }); |
| 385 | checkURL("http://\t//\\///user:@webkit.org:99?foo" , {"http" , "user" , "" , "webkit.org" , 99, "/" , "foo" , "" , "http://user@webkit.org:99/?foo" }); |
| 386 | checkURL("http:/\\user:@webkit.org:99?foo" , {"http" , "user" , "" , "webkit.org" , 99, "/" , "foo" , "" , "http://user@webkit.org:99/?foo" }); |
| 387 | checkURL("http://127.0.0.1" , {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1/" }); |
| 388 | checkURLDifferences("http://127.0.0.1." , |
| 389 | {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1/" }, |
| 390 | {"http" , "" , "" , "127.0.0.1." , 0, "/" , "" , "" , "http://127.0.0.1./" }); |
| 391 | checkURLDifferences("http://127.0.0.1./" , |
| 392 | {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1/" }, |
| 393 | {"http" , "" , "" , "127.0.0.1." , 0, "/" , "" , "" , "http://127.0.0.1./" }); |
| 394 | checkURL("http://127.0.0.1../" , {"http" , "" , "" , "127.0.0.1.." , 0, "/" , "" , "" , "http://127.0.0.1../" }); |
| 395 | checkURLDifferences("http://0x100.0/" , |
| 396 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://0x100.0/" }, |
| 397 | {"http" , "" , "" , "0x100.0" , 0, "/" , "" , "" , "http://0x100.0/" }); |
| 398 | checkURLDifferences("http://0.0.0x100.0/" , |
| 399 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://0.0.0x100.0/" }, |
| 400 | {"http" , "" , "" , "0.0.0x100.0" , 0, "/" , "" , "" , "http://0.0.0x100.0/" }); |
| 401 | checkURLDifferences("http://0.0.0.0x100/" , |
| 402 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://0.0.0.0x100/" }, |
| 403 | {"http" , "" , "" , "0.0.0.0x100" , 0, "/" , "" , "" , "http://0.0.0.0x100/" }); |
| 404 | checkURL("http://host:123?" , {"http" , "" , "" , "host" , 123, "/" , "" , "" , "http://host:123/?" }); |
| 405 | checkURL("http://host:123?query" , {"http" , "" , "" , "host" , 123, "/" , "query" , "" , "http://host:123/?query" }); |
| 406 | checkURL("http://host:123#" , {"http" , "" , "" , "host" , 123, "/" , "" , "" , "http://host:123/#" }); |
| 407 | checkURL("http://host:123#fragment" , {"http" , "" , "" , "host" , 123, "/" , "" , "fragment" , "http://host:123/#fragment" }); |
| 408 | checkURLDifferences("foo:////" , |
| 409 | {"foo" , "" , "" , "" , 0, "//" , "" , "" , "foo:////" }, |
| 410 | {"foo" , "" , "" , "" , 0, "////" , "" , "" , "foo:////" }); |
| 411 | checkURLDifferences("foo:///?" , |
| 412 | {"foo" , "" , "" , "" , 0, "/" , "" , "" , "foo:///?" }, |
| 413 | {"foo" , "" , "" , "" , 0, "///" , "" , "" , "foo:///?" }); |
| 414 | checkURLDifferences("foo:///#" , |
| 415 | {"foo" , "" , "" , "" , 0, "/" , "" , "" , "foo:///#" }, |
| 416 | {"foo" , "" , "" , "" , 0, "///" , "" , "" , "foo:///#" }); |
| 417 | checkURLDifferences("foo:///" , |
| 418 | {"foo" , "" , "" , "" , 0, "/" , "" , "" , "foo:///" }, |
| 419 | {"foo" , "" , "" , "" , 0, "///" , "" , "" , "foo:///" }); |
| 420 | checkURLDifferences("foo://?" , |
| 421 | {"foo" , "" , "" , "" , 0, "" , "" , "" , "foo://?" }, |
| 422 | {"foo" , "" , "" , "" , 0, "//" , "" , "" , "foo://?" }); |
| 423 | checkURLDifferences("foo://#" , |
| 424 | {"foo" , "" , "" , "" , 0, "" , "" , "" , "foo://#" }, |
| 425 | {"foo" , "" , "" , "" , 0, "//" , "" , "" , "foo://#" }); |
| 426 | checkURLDifferences("foo://" , |
| 427 | {"foo" , "" , "" , "" , 0, "" , "" , "" , "foo://" }, |
| 428 | {"foo" , "" , "" , "" , 0, "//" , "" , "" , "foo://" }); |
| 429 | checkURL("foo:/?" , {"foo" , "" , "" , "" , 0, "/" , "" , "" , "foo:/?" }); |
| 430 | checkURL("foo:/#" , {"foo" , "" , "" , "" , 0, "/" , "" , "" , "foo:/#" }); |
| 431 | checkURL("foo:/" , {"foo" , "" , "" , "" , 0, "/" , "" , "" , "foo:/" }); |
| 432 | checkURL("foo:?" , {"foo" , "" , "" , "" , 0, "" , "" , "" , "foo:?" }); |
| 433 | checkURL("foo:#" , {"foo" , "" , "" , "" , 0, "" , "" , "" , "foo:#" }); |
| 434 | checkURLDifferences("A://" , |
| 435 | {"a" , "" , "" , "" , 0, "" , "" , "" , "a://" }, |
| 436 | {"a" , "" , "" , "" , 0, "//" , "" , "" , "a://" }); |
| 437 | checkURLDifferences("aA://" , |
| 438 | {"aa" , "" , "" , "" , 0, "" , "" , "" , "aa://" }, |
| 439 | {"aa" , "" , "" , "" , 0, "//" , "" , "" , "aa://" }); |
| 440 | checkURL(utf16String(u"foo://host/#ПП\u0007 a</" ), {"foo" , "" , "" , "host" , 0, "/" , "" , "%D0%9F%D0%9F%07 a</" , "foo://host/#%D0%9F%D0%9F%07 a</" }); |
| 441 | checkURL(utf16String(u"foo://host/#\u0007 a</" ), {"foo" , "" , "" , "host" , 0, "/" , "" , "%07 a</" , "foo://host/#%07 a</" }); |
| 442 | checkURL(utf16String(u"http://host?ß😍#ß😍" ), {"http" , "" , "" , "host" , 0, "/" , "%C3%9F%F0%9F%98%8D" , "%C3%9F%F0%9F%98%8D" , "http://host/?%C3%9F%F0%9F%98%8D#%C3%9F%F0%9F%98%8D" }, testTabsValueForSurrogatePairs); |
| 443 | checkURL(utf16String(u"http://host/path#💩\t💩" ), {"http" , "" , "" , "host" , 0, "/path" , "" , "%F0%9F%92%A9%F0%9F%92%A9" , "http://host/path#%F0%9F%92%A9%F0%9F%92%A9" }, testTabsValueForSurrogatePairs); |
| 444 | checkURL(utf16String(u"http://host/#ПП\u0007 a</" ), {"http" , "" , "" , "host" , 0, "/" , "" , "%D0%9F%D0%9F%07 a</" , "http://host/#%D0%9F%D0%9F%07 a</" }); |
| 445 | checkURL(utf16String(u"http://host/#\u0007 a</" ), {"http" , "" , "" , "host" , 0, "/" , "" , "%07 a</" , "http://host/#%07 a</" }); |
| 446 | |
| 447 | // This disagrees with the web platform test for http://:@www.example.com but agrees with Chrome and URL::parse, |
| 448 | // and Firefox fails the web platform test differently. Maybe the web platform test ought to be changed. |
| 449 | checkURL("http://:@host" , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 450 | } |
| 451 | |
| 452 | static void testUserPass(const String& value, const String& decoded, const String& encoded) |
| 453 | { |
| 454 | URL userURL(URL(), makeString("http://" , value, "@example.com/" )); |
| 455 | URL passURL(URL(), makeString("http://user:" , value, "@example.com/" )); |
| 456 | EXPECT_EQ(encoded, userURL.encodedUser()); |
| 457 | EXPECT_EQ(encoded, passURL.encodedPass()); |
| 458 | EXPECT_EQ(decoded, userURL.user()); |
| 459 | EXPECT_EQ(decoded, passURL.pass()); |
| 460 | } |
| 461 | |
| 462 | static void testUserPass(const String& value, const String& encoded) |
| 463 | { |
| 464 | testUserPass(value, value, encoded); |
| 465 | } |
| 466 | |
| 467 | TEST_F(WTF_URLParser, Credentials) |
| 468 | { |
| 469 | auto validSurrogate = utf16String<3>({0xD800, 0xDD55, '\0'}); |
| 470 | auto invalidSurrogate = utf16String<3>({0xD800, 'A', '\0'}); |
| 471 | auto replacementA = utf16String<3>({0xFFFD, 'A', '\0'}); |
| 472 | |
| 473 | testUserPass("a" , "a" ); |
| 474 | testUserPass("%" , "%" ); |
| 475 | testUserPass("%25" , "%" , "%25" ); |
| 476 | testUserPass("%2525" , "%25" , "%2525" ); |
| 477 | testUserPass("%FX" , "%FX" ); |
| 478 | testUserPass("%00" , String::fromUTF8("\0" , 1), "%00" ); |
| 479 | testUserPass("%F%25" , "%F%" , "%F%25" ); |
| 480 | testUserPass("%X%25" , "%X%" , "%X%25" ); |
| 481 | testUserPass("%%25" , "%%" , "%%25" ); |
| 482 | testUserPass("💩" , "%C3%B0%C2%9F%C2%92%C2%A9" ); |
| 483 | testUserPass("%💩" , "%%C3%B0%C2%9F%C2%92%C2%A9" ); |
| 484 | testUserPass(validSurrogate, "%F0%90%85%95" ); |
| 485 | testUserPass(replacementA, "%EF%BF%BDA" ); |
| 486 | testUserPass(invalidSurrogate, replacementA, "%EF%BF%BDA" ); |
| 487 | } |
| 488 | |
| 489 | TEST_F(WTF_URLParser, ParseRelative) |
| 490 | { |
| 491 | checkRelativeURL("/index.html" , "http://webkit.org/path1/path2/" , {"http" , "" , "" , "webkit.org" , 0, "/index.html" , "" , "" , "http://webkit.org/index.html" }); |
| 492 | checkRelativeURL("http://whatwg.org/index.html" , "http://webkit.org/path1/path2/" , {"http" , "" , "" , "whatwg.org" , 0, "/index.html" , "" , "" , "http://whatwg.org/index.html" }); |
| 493 | checkRelativeURL("index.html" , "http://webkit.org/path1/path2/page.html?query#fragment" , {"http" , "" , "" , "webkit.org" , 0, "/path1/path2/index.html" , "" , "" , "http://webkit.org/path1/path2/index.html" }); |
| 494 | checkRelativeURL("//whatwg.org/index.html" , "https://www.webkit.org/path" , {"https" , "" , "" , "whatwg.org" , 0, "/index.html" , "" , "" , "https://whatwg.org/index.html" }); |
| 495 | checkRelativeURL("http://example\t.\norg" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/" , "" , "" , "http://example.org/" }); |
| 496 | checkRelativeURL("test" , "file:///path1/path2" , {"file" , "" , "" , "" , 0, "/path1/test" , "" , "" , "file:///path1/test" }); |
| 497 | checkRelativeURL(utf16String(u"http://www.foo。bar.com" ), "http://other.com/" , {"http" , "" , "" , "www.foo.bar.com" , 0, "/" , "" , "" , "http://www.foo.bar.com/" }); |
| 498 | checkRelativeURLDifferences(utf16String(u"sc://ñ.test/" ), "about:blank" , |
| 499 | {"sc" , "" , "" , "%C3%B1.test" , 0, "/" , "" , "" , "sc://%C3%B1.test/" }, |
| 500 | {"sc" , "" , "" , "xn--ida.test" , 0, "/" , "" , "" , "sc://xn--ida.test/" }); |
| 501 | checkRelativeURL("#fragment" , "http://host/path" , {"http" , "" , "" , "host" , 0, "/path" , "" , "fragment" , "http://host/path#fragment" }); |
| 502 | checkRelativeURL("#fragment" , "file:///path" , {"file" , "" , "" , "" , 0, "/path" , "" , "fragment" , "file:///path#fragment" }); |
| 503 | checkRelativeURL("#fragment" , "file:///path#old" , {"file" , "" , "" , "" , 0, "/path" , "" , "fragment" , "file:///path#fragment" }); |
| 504 | checkRelativeURL("#" , "file:///path#old" , {"file" , "" , "" , "" , 0, "/path" , "" , "" , "file:///path#" }); |
| 505 | checkRelativeURL(" " , "file:///path#old" , {"file" , "" , "" , "" , 0, "/path" , "" , "" , "file:///path" }); |
| 506 | checkRelativeURL("#" , "file:///path" , {"file" , "" , "" , "" , 0, "/path" , "" , "" , "file:///path#" }); |
| 507 | checkRelativeURL("#" , "file:///path?query" , {"file" , "" , "" , "" , 0, "/path" , "query" , "" , "file:///path?query#" }); |
| 508 | checkRelativeURL("#" , "file:///path?query#old" , {"file" , "" , "" , "" , 0, "/path" , "query" , "" , "file:///path?query#" }); |
| 509 | checkRelativeURL("?query" , "http://host/path" , {"http" , "" , "" , "host" , 0, "/path" , "query" , "" , "http://host/path?query" }); |
| 510 | checkRelativeURL("?query#fragment" , "http://host/path" , {"http" , "" , "" , "host" , 0, "/path" , "query" , "fragment" , "http://host/path?query#fragment" }); |
| 511 | checkRelativeURL("?new" , "file:///path?old#fragment" , {"file" , "" , "" , "" , 0, "/path" , "new" , "" , "file:///path?new" }); |
| 512 | checkRelativeURL("?" , "file:///path?old#fragment" , {"file" , "" , "" , "" , 0, "/path" , "" , "" , "file:///path?" }); |
| 513 | checkRelativeURL("?" , "file:///path" , {"file" , "" , "" , "" , 0, "/path" , "" , "" , "file:///path?" }); |
| 514 | checkRelativeURL("?query" , "file:///path" , {"file" , "" , "" , "" , 0, "/path" , "query" , "" , "file:///path?query" }); |
| 515 | checkRelativeURL(utf16String(u"?β" ), "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/bar" , "%CE%B2" , "" , "http://example.org/foo/bar?%CE%B2" }); |
| 516 | checkRelativeURL("?" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/bar" , "" , "" , "http://example.org/foo/bar?" }); |
| 517 | checkRelativeURL("#" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/bar" , "" , "" , "http://example.org/foo/bar#" }); |
| 518 | checkRelativeURL("?#" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/bar" , "" , "" , "http://example.org/foo/bar?#" }); |
| 519 | checkRelativeURL("#?" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/bar" , "" , "?" , "http://example.org/foo/bar#?" }); |
| 520 | checkRelativeURL("/" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/" , "" , "" , "http://example.org/" }); |
| 521 | checkRelativeURL("http://@host" , "about:blank" , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 522 | checkRelativeURL("http://:@host" , "about:blank" , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 523 | checkRelativeURL("http://foo.com/\\@" , "http://example.org/foo/bar" , {"http" , "" , "" , "foo.com" , 0, "//@" , "" , "" , "http://foo.com//@" }); |
| 524 | checkRelativeURL("\\@" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/@" , "" , "" , "http://example.org/@" }); |
| 525 | checkRelativeURL("/path3" , "http://user@example.org/path1/path2" , {"http" , "user" , "" , "example.org" , 0, "/path3" , "" , "" , "http://user@example.org/path3" }); |
| 526 | checkRelativeURL("" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/bar" , "" , "" , "http://example.org/foo/bar" }); |
| 527 | checkRelativeURL("\t" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/bar" , "" , "" , "http://example.org/foo/bar" }); |
| 528 | checkRelativeURL(" " , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/bar" , "" , "" , "http://example.org/foo/bar" }); |
| 529 | checkRelativeURL(" \a \t\n" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/bar" , "" , "" , "http://example.org/foo/bar" }); |
| 530 | checkRelativeURL(":foo.com\\" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/:foo.com/" , "" , "" , "http://example.org/foo/:foo.com/" }); |
| 531 | checkRelativeURL("http:/example.com/" , "about:blank" , {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }); |
| 532 | checkRelativeURL("http:example.com/" , "about:blank" , {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }); |
| 533 | checkRelativeURL("http:\\\\foo.com\\" , "http://example.org/foo/bar" , {"http" , "" , "" , "foo.com" , 0, "/" , "" , "" , "http://foo.com/" }); |
| 534 | checkRelativeURL("http:\\\\foo.com/" , "http://example.org/foo/bar" , {"http" , "" , "" , "foo.com" , 0, "/" , "" , "" , "http://foo.com/" }); |
| 535 | checkRelativeURL("http:\\\\foo.com" , "http://example.org/foo/bar" , {"http" , "" , "" , "foo.com" , 0, "/" , "" , "" , "http://foo.com/" }); |
| 536 | checkRelativeURL("http://ExAmPlE.CoM" , "http://other.com" , {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }); |
| 537 | checkRelativeURL("http:" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/bar" , "" , "" , "http://example.org/foo/bar" }); |
| 538 | checkRelativeURL("#x" , "data:," , {"data" , "" , "" , "" , 0, "," , "" , "x" , "data:,#x" }); |
| 539 | checkRelativeURL("#x" , "about:blank" , {"about" , "" , "" , "" , 0, "blank" , "" , "x" , "about:blank#x" }); |
| 540 | checkRelativeURL(" foo.com " , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/foo.com" , "" , "" , "http://example.org/foo/foo.com" }); |
| 541 | checkRelativeURL(" \a baz" , "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/baz" , "" , "" , "http://example.org/foo/baz" }); |
| 542 | checkRelativeURL("~" , "http://example.org" , {"http" , "" , "" , "example.org" , 0, "/~" , "" , "" , "http://example.org/~" }); |
| 543 | checkRelativeURL("notspecial:" , "about:blank" , {"notspecial" , "" , "" , "" , 0, "" , "" , "" , "notspecial:" }); |
| 544 | checkRelativeURL("notspecial:" , "http://host" , {"notspecial" , "" , "" , "" , 0, "" , "" , "" , "notspecial:" }); |
| 545 | checkRelativeURL("http:" , "http://host" , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 546 | checkRelativeURL("i" , "sc:/pa/po" , {"sc" , "" , "" , "" , 0, "/pa/i" , "" , "" , "sc:/pa/i" }); |
| 547 | checkRelativeURL("i " , "sc:/pa/po" , {"sc" , "" , "" , "" , 0, "/pa/i" , "" , "" , "sc:/pa/i" }); |
| 548 | checkRelativeURL("i\t\n " , "sc:/pa/po" , {"sc" , "" , "" , "" , 0, "/pa/i" , "" , "" , "sc:/pa/i" }); |
| 549 | checkRelativeURL("i" , "sc://ho/pa" , {"sc" , "" , "" , "ho" , 0, "/i" , "" , "" , "sc://ho/i" }); |
| 550 | checkRelativeURL("!" , "sc://ho/pa" , {"sc" , "" , "" , "ho" , 0, "/!" , "" , "" , "sc://ho/!" }); |
| 551 | checkRelativeURL("!" , "sc:/ho/pa" , {"sc" , "" , "" , "" , 0, "/ho/!" , "" , "" , "sc:/ho/!" }); |
| 552 | checkRelativeURL("notspecial:/" , "about:blank" , {"notspecial" , "" , "" , "" , 0, "/" , "" , "" , "notspecial:/" }); |
| 553 | checkRelativeURL("notspecial:/" , "http://host" , {"notspecial" , "" , "" , "" , 0, "/" , "" , "" , "notspecial:/" }); |
| 554 | checkRelativeURL("foo:/" , "http://example.org/foo/bar" , {"foo" , "" , "" , "" , 0, "/" , "" , "" , "foo:/" }); |
| 555 | checkRelativeURL("://:0/" , "http://webkit.org/" , {"http" , "" , "" , "webkit.org" , 0, "/://:0/" , "" , "" , "http://webkit.org/://:0/" }); |
| 556 | checkRelativeURL(String(), "http://webkit.org/" , {"http" , "" , "" , "webkit.org" , 0, "/" , "" , "" , "http://webkit.org/" }); |
| 557 | checkRelativeURL("https://@test@test@example:800\\path@end" , "http://doesnotmatter/" , {"" , "" , "" , "" , 0, "" , "" , "" , "https://@test@test@example:800\\path@end" }); |
| 558 | checkRelativeURL("http://f:0/c" , "http://example.org/foo/bar" , {"http" , "" , "" , "f" , 0, "/c" , "" , "" , "http://f:0/c" }); |
| 559 | checkRelativeURL(String(), "http://host/#fragment" , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 560 | checkRelativeURL("" , "http://host/#fragment" , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 561 | checkRelativeURL(" " , "http://host/#fragment" , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 562 | checkRelativeURL(" " , "http://host/path?query#fra#gment" , {"http" , "" , "" , "host" , 0, "/path" , "query" , "" , "http://host/path?query" }); |
| 563 | checkRelativeURL(" \a " , "http://host/#fragment" , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 564 | checkRelativeURLDifferences("foo://" , "http://example.org/foo/bar" , |
| 565 | {"foo" , "" , "" , "" , 0, "" , "" , "" , "foo://" }, |
| 566 | {"foo" , "" , "" , "" , 0, "//" , "" , "" , "foo://" }); |
| 567 | checkRelativeURL(utf16String(u"#β" ), "http://example.org/foo/bar" , {"http" , "" , "" , "example.org" , 0, "/foo/bar" , "" , "%CE%B2" , "http://example.org/foo/bar#%CE%B2" }); |
| 568 | checkRelativeURL("index.html" , "applewebdata://Host/" , {"applewebdata" , "" , "" , "Host" , 0, "/index.html" , "" , "" , "applewebdata://Host/index.html" }); |
| 569 | checkRelativeURL("index.html" , "applewebdata://Host" , {"applewebdata" , "" , "" , "Host" , 0, "/index.html" , "" , "" , "applewebdata://Host/index.html" }); |
| 570 | checkRelativeURL("" , "applewebdata://Host" , {"applewebdata" , "" , "" , "Host" , 0, "" , "" , "" , "applewebdata://Host" }); |
| 571 | checkRelativeURL("?query" , "applewebdata://Host" , {"applewebdata" , "" , "" , "Host" , 0, "" , "query" , "" , "applewebdata://Host?query" }); |
| 572 | checkRelativeURL("#fragment" , "applewebdata://Host" , {"applewebdata" , "" , "" , "Host" , 0, "" , "" , "fragment" , "applewebdata://Host#fragment" }); |
| 573 | checkRelativeURL("notspecial://something?" , "file:////var//containers//stuff/" , {"notspecial" , "" , "" , "something" , 0, "" , "" , "" , "notspecial://something?" }, TestTabs::No); |
| 574 | checkRelativeURL("notspecial://something#" , "file:////var//containers//stuff/" , {"notspecial" , "" , "" , "something" , 0, "" , "" , "" , "notspecial://something#" }, TestTabs::No); |
| 575 | checkRelativeURL("http://something?" , "file:////var//containers//stuff/" , {"http" , "" , "" , "something" , 0, "/" , "" , "" , "http://something/?" }, TestTabs::No); |
| 576 | checkRelativeURL("http://something#" , "file:////var//containers//stuff/" , {"http" , "" , "" , "something" , 0, "/" , "" , "" , "http://something/#" }, TestTabs::No); |
| 577 | checkRelativeURL("file:" , "file:///path?query#fragment" , {"file" , "" , "" , "" , 0, "/path" , "query" , "" , "file:///path?query" }); |
| 578 | checkRelativeURL("/" , "file:///C:/a/b" , {"file" , "" , "" , "" , 0, "/C:/" , "" , "" , "file:///C:/" }); |
| 579 | checkRelativeURL("/abc" , "file:///C:/a/b" , {"file" , "" , "" , "" , 0, "/C:/abc" , "" , "" , "file:///C:/abc" }); |
| 580 | checkRelativeURL("/abc" , "file:///C:" , {"file" , "" , "" , "" , 0, "/C:/abc" , "" , "" , "file:///C:/abc" }); |
| 581 | checkRelativeURL("/abc" , "file:///" , {"file" , "" , "" , "" , 0, "/abc" , "" , "" , "file:///abc" }); |
| 582 | checkRelativeURL("//d:" , "file:///C:/a/b" , {"file" , "" , "" , "" , 0, "/d:" , "" , "" , "file:///d:" }, TestTabs::No); |
| 583 | checkRelativeURL("//d|" , "file:///C:/a/b" , {"file" , "" , "" , "" , 0, "/d:" , "" , "" , "file:///d:" }, TestTabs::No); |
| 584 | checkRelativeURL("//A|" , "file:///C:/a/b" , {"file" , "" , "" , "" , 0, "/A:" , "" , "" , "file:///A:" }, TestTabs::No); |
| 585 | |
| 586 | // The checking of slashes in SpecialAuthoritySlashes needed to get this to pass contradicts what is in the spec, |
| 587 | // but it is included in the web platform tests. |
| 588 | checkRelativeURL("http:\\\\host\\foo" , "about:blank" , {"http" , "" , "" , "host" , 0, "/foo" , "" , "" , "http://host/foo" }); |
| 589 | } |
| 590 | |
| 591 | // These are differences between the new URLParser and the old URL::parse which make URLParser more standards compliant. |
| 592 | TEST_F(WTF_URLParser, ParserDifferences) |
| 593 | { |
| 594 | checkURLDifferences("http://127.0.1" , |
| 595 | {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1/" }, |
| 596 | {"http" , "" , "" , "127.0.1" , 0, "/" , "" , "" , "http://127.0.1/" }); |
| 597 | checkURLDifferences("http://011.11.0X11.0x011" , |
| 598 | {"http" , "" , "" , "9.11.17.17" , 0, "/" , "" , "" , "http://9.11.17.17/" }, |
| 599 | {"http" , "" , "" , "011.11.0x11.0x011" , 0, "/" , "" , "" , "http://011.11.0x11.0x011/" }); |
| 600 | checkURLDifferences("http://[1234:0078:90AB:CdEf:0123:0007:89AB:0000]" , |
| 601 | {"http" , "" , "" , "[1234:78:90ab:cdef:123:7:89ab:0]" , 0, "/" , "" , "" , "http://[1234:78:90ab:cdef:123:7:89ab:0]/" }, |
| 602 | {"http" , "" , "" , "[1234:0078:90ab:cdef:0123:0007:89ab:0000]" , 0, "/" , "" , "" , "http://[1234:0078:90ab:cdef:0123:0007:89ab:0000]/" }); |
| 603 | checkURLDifferences("http://[0:f:0:0:f:f:0:0]" , |
| 604 | {"http" , "" , "" , "[0:f::f:f:0:0]" , 0, "/" , "" , "" , "http://[0:f::f:f:0:0]/" }, |
| 605 | {"http" , "" , "" , "[0:f:0:0:f:f:0:0]" , 0, "/" , "" , "" , "http://[0:f:0:0:f:f:0:0]/" }); |
| 606 | checkURLDifferences("http://[0:f:0:0:f:0:0:0]" , |
| 607 | {"http" , "" , "" , "[0:f:0:0:f::]" , 0, "/" , "" , "" , "http://[0:f:0:0:f::]/" }, |
| 608 | {"http" , "" , "" , "[0:f:0:0:f:0:0:0]" , 0, "/" , "" , "" , "http://[0:f:0:0:f:0:0:0]/" }); |
| 609 | checkURLDifferences("http://[0:0:f:0:0:f:0:0]" , |
| 610 | {"http" , "" , "" , "[::f:0:0:f:0:0]" , 0, "/" , "" , "" , "http://[::f:0:0:f:0:0]/" }, |
| 611 | {"http" , "" , "" , "[0:0:f:0:0:f:0:0]" , 0, "/" , "" , "" , "http://[0:0:f:0:0:f:0:0]/" }); |
| 612 | checkURLDifferences("http://[a:0:0:0:b:c::d]" , |
| 613 | {"http" , "" , "" , "[a::b:c:0:d]" , 0, "/" , "" , "" , "http://[a::b:c:0:d]/" }, |
| 614 | {"http" , "" , "" , "[a:0:0:0:b:c::d]" , 0, "/" , "" , "" , "http://[a:0:0:0:b:c::d]/" }); |
| 615 | checkURLDifferences("http://[::7f00:0001]/" , |
| 616 | {"http" , "" , "" , "[::7f00:1]" , 0, "/" , "" , "" , "http://[::7f00:1]/" }, |
| 617 | {"http" , "" , "" , "[::7f00:0001]" , 0, "/" , "" , "" , "http://[::7f00:0001]/" }); |
| 618 | checkURLDifferences("http://[::7f00:00]/" , |
| 619 | {"http" , "" , "" , "[::7f00:0]" , 0, "/" , "" , "" , "http://[::7f00:0]/" }, |
| 620 | {"http" , "" , "" , "[::7f00:00]" , 0, "/" , "" , "" , "http://[::7f00:00]/" }); |
| 621 | checkURLDifferences("http://[::0:7f00:0001]/" , |
| 622 | {"http" , "" , "" , "[::7f00:1]" , 0, "/" , "" , "" , "http://[::7f00:1]/" }, |
| 623 | {"http" , "" , "" , "[::0:7f00:0001]" , 0, "/" , "" , "" , "http://[::0:7f00:0001]/" }); |
| 624 | checkURLDifferences("http://127.00.0.1/" , |
| 625 | {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1/" }, |
| 626 | {"http" , "" , "" , "127.00.0.1" , 0, "/" , "" , "" , "http://127.00.0.1/" }); |
| 627 | checkURLDifferences("http://127.0.0.01/" , |
| 628 | {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1/" }, |
| 629 | {"http" , "" , "" , "127.0.0.01" , 0, "/" , "" , "" , "http://127.0.0.01/" }); |
| 630 | checkURLDifferences("http://example.com/path1/.%2e" , |
| 631 | {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }, |
| 632 | {"http" , "" , "" , "example.com" , 0, "/path1/.%2e" , "" , "" , "http://example.com/path1/.%2e" }); |
| 633 | checkURLDifferences("http://example.com/path1/.%2E" , |
| 634 | {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }, |
| 635 | {"http" , "" , "" , "example.com" , 0, "/path1/.%2E" , "" , "" , "http://example.com/path1/.%2E" }); |
| 636 | checkURLDifferences("http://example.com/path1/.%2E/" , |
| 637 | {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }, |
| 638 | {"http" , "" , "" , "example.com" , 0, "/path1/.%2E/" , "" , "" , "http://example.com/path1/.%2E/" }); |
| 639 | checkURLDifferences("http://example.com/path1/%2e." , |
| 640 | {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }, |
| 641 | {"http" , "" , "" , "example.com" , 0, "/path1/%2e." , "" , "" , "http://example.com/path1/%2e." }); |
| 642 | checkURLDifferences("http://example.com/path1/%2E%2e" , |
| 643 | {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }, |
| 644 | {"http" , "" , "" , "example.com" , 0, "/path1/%2E%2e" , "" , "" , "http://example.com/path1/%2E%2e" }); |
| 645 | checkURLDifferences("http://example.com/path1/%2e" , |
| 646 | {"http" , "" , "" , "example.com" , 0, "/path1/" , "" , "" , "http://example.com/path1/" }, |
| 647 | {"http" , "" , "" , "example.com" , 0, "/path1/%2e" , "" , "" , "http://example.com/path1/%2e" }); |
| 648 | checkURLDifferences("http://example.com/path1/%2E" , |
| 649 | {"http" , "" , "" , "example.com" , 0, "/path1/" , "" , "" , "http://example.com/path1/" }, |
| 650 | {"http" , "" , "" , "example.com" , 0, "/path1/%2E" , "" , "" , "http://example.com/path1/%2E" }); |
| 651 | checkURLDifferences("http://example.com/path1/%2E/" , |
| 652 | {"http" , "" , "" , "example.com" , 0, "/path1/" , "" , "" , "http://example.com/path1/" }, |
| 653 | {"http" , "" , "" , "example.com" , 0, "/path1/%2E/" , "" , "" , "http://example.com/path1/%2E/" }); |
| 654 | checkURLDifferences("http://example.com/path1/path2/%2e?query" , |
| 655 | {"http" , "" , "" , "example.com" , 0, "/path1/path2/" , "query" , "" , "http://example.com/path1/path2/?query" }, |
| 656 | {"http" , "" , "" , "example.com" , 0, "/path1/path2/%2e" , "query" , "" , "http://example.com/path1/path2/%2e?query" }); |
| 657 | checkURLDifferences("http://example.com/path1/path2/%2e%2e?query" , |
| 658 | {"http" , "" , "" , "example.com" , 0, "/path1/" , "query" , "" , "http://example.com/path1/?query" }, |
| 659 | {"http" , "" , "" , "example.com" , 0, "/path1/path2/%2e%2e" , "query" , "" , "http://example.com/path1/path2/%2e%2e?query" }); |
| 660 | checkURLDifferences("http://example.com/path1/path2/%2e#fragment" , |
| 661 | {"http" , "" , "" , "example.com" , 0, "/path1/path2/" , "" , "fragment" , "http://example.com/path1/path2/#fragment" }, |
| 662 | {"http" , "" , "" , "example.com" , 0, "/path1/path2/%2e" , "" , "fragment" , "http://example.com/path1/path2/%2e#fragment" }); |
| 663 | checkURLDifferences("http://example.com/path1/path2/%2e%2e#fragment" , |
| 664 | {"http" , "" , "" , "example.com" , 0, "/path1/" , "" , "fragment" , "http://example.com/path1/#fragment" }, |
| 665 | {"http" , "" , "" , "example.com" , 0, "/path1/path2/%2e%2e" , "" , "fragment" , "http://example.com/path1/path2/%2e%2e#fragment" }); |
| 666 | checkURL("http://example.com/path1/path2/A%2e%2e#fragment" , {"http" , "" , "" , "example.com" , 0, "/path1/path2/A%2e%2e" , "" , "fragment" , "http://example.com/path1/path2/A%2e%2e#fragment" }); |
| 667 | checkURLDifferences("file://[0:a:0:0:b:c:0:0]/path" , |
| 668 | {"file" , "" , "" , "[0:a::b:c:0:0]" , 0, "/path" , "" , "" , "file://[0:a::b:c:0:0]/path" }, |
| 669 | {"file" , "" , "" , "[0:a:0:0:b:c:0:0]" , 0, "/path" , "" , "" , "file://[0:a:0:0:b:c:0:0]/path" }); |
| 670 | checkURLDifferences("http://" , |
| 671 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://" }, |
| 672 | {"http" , "" , "" , "" , 0, "/" , "" , "" , "http:/" }); |
| 673 | checkRelativeURLDifferences("//" , "https://www.webkit.org/path" , |
| 674 | {"" , "" , "" , "" , 0, "" , "" , "" , "//" }, |
| 675 | {"https" , "" , "" , "" , 0, "/" , "" , "" , "https:/" }); |
| 676 | checkURLDifferences("http://127.0.0.1:65536/path" , |
| 677 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://127.0.0.1:65536/path" }, |
| 678 | {"http" , "" , "" , "127.0.0.1" , 0, "/path" , "" , "" , "http://127.0.0.1:65536/path" }); |
| 679 | checkURLDifferences("http://host:65536" , |
| 680 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://host:65536" }, |
| 681 | {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host:65536/" }); |
| 682 | checkURLDifferences("http://127.0.0.1:65536" , |
| 683 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://127.0.0.1:65536" }, |
| 684 | {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1:65536/" }); |
| 685 | checkURLDifferences("http://[0:f::f:f:0:0]:65536" , |
| 686 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[0:f::f:f:0:0]:65536" }, |
| 687 | {"http" , "" , "" , "[0:f::f:f:0:0]" , 0, "/" , "" , "" , "http://[0:f::f:f:0:0]:65536/" }); |
| 688 | checkRelativeURLDifferences(":foo.com\\" , "notspecial://example.org/foo/bar" , |
| 689 | {"notspecial" , "" , "" , "example.org" , 0, "/foo/:foo.com\\" , "" , "" , "notspecial://example.org/foo/:foo.com\\" }, |
| 690 | {"notspecial" , "" , "" , "example.org" , 0, "/foo/:foo.com/" , "" , "" , "notspecial://example.org/foo/:foo.com/" }); |
| 691 | checkURL("sc://pa" , {"sc" , "" , "" , "pa" , 0, "" , "" , "" , "sc://pa" }); |
| 692 | checkRelativeURLDifferences("notspecial:\\\\foo.com\\" , "http://example.org/foo/bar" , |
| 693 | {"notspecial" , "" , "" , "" , 0, "\\\\foo.com\\" , "" , "" , "notspecial:\\\\foo.com\\" }, |
| 694 | {"notspecial" , "" , "" , "foo.com" , 0, "/" , "" , "" , "notspecial://foo.com/" }); |
| 695 | checkRelativeURLDifferences("notspecial:\\\\foo.com/" , "http://example.org/foo/bar" , |
| 696 | {"notspecial" , "" , "" , "" , 0, "\\\\foo.com/" , "" , "" , "notspecial:\\\\foo.com/" }, |
| 697 | {"notspecial" , "" , "" , "foo.com" , 0, "/" , "" , "" , "notspecial://foo.com/" }); |
| 698 | checkRelativeURLDifferences("notspecial:\\\\foo.com" , "http://example.org/foo/bar" , |
| 699 | {"notspecial" , "" , "" , "" , 0, "\\\\foo.com" , "" , "" , "notspecial:\\\\foo.com" }, |
| 700 | {"notspecial" , "" , "" , "foo.com" , 0, "" , "" , "" , "notspecial://foo.com" }); |
| 701 | checkURLDifferences("file://notuser:notpassword@test" , |
| 702 | {"" , "" , "" , "" , 0, "" , "" , "" , "file://notuser:notpassword@test" }, |
| 703 | {"file" , "notuser" , "notpassword" , "test" , 0, "/" , "" , "" , "file://notuser:notpassword@test/" }); |
| 704 | checkURLDifferences("file://notuser:notpassword@test/" , |
| 705 | {"" , "" , "" , "" , 0, "" , "" , "" , "file://notuser:notpassword@test/" }, |
| 706 | {"file" , "notuser" , "notpassword" , "test" , 0, "/" , "" , "" , "file://notuser:notpassword@test/" }); |
| 707 | checkRelativeURLDifferences("http:/" , "about:blank" , |
| 708 | {"" , "" , "" , "" , 0, "" , "" , "" , "http:/" }, |
| 709 | {"http" , "" , "" , "" , 0, "/" , "" , "" , "http:/" }); |
| 710 | checkRelativeURLDifferences("http:" , "about:blank" , |
| 711 | {"http" , "" , "" , "" , 0, "" , "" , "" , "http:" }, |
| 712 | {"http" , "" , "" , "" , 0, "/" , "" , "" , "http:/" }); |
| 713 | checkRelativeURLDifferences("http:/" , "http://host" , |
| 714 | {"" , "" , "" , "" , 0, "" , "" , "" , "http:/" }, |
| 715 | {"http" , "" , "" , "" , 0, "/" , "" , "" , "http:/" }); |
| 716 | checkURLDifferences("http:/" , |
| 717 | {"" , "" , "" , "" , 0, "" , "" , "" , "http:/" }, |
| 718 | {"http" , "" , "" , "" , 0, "/" , "" , "" , "http:/" }); |
| 719 | checkURLDifferences("http:" , |
| 720 | {"http" , "" , "" , "" , 0, "" , "" , "" , "http:" }, |
| 721 | {"http" , "" , "" , "" , 0, "/" , "" , "" , "http:/" }); |
| 722 | checkRelativeURLDifferences("http:/example.com/" , "http://example.org/foo/bar" , |
| 723 | {"http" , "" , "" , "example.org" , 0, "/example.com/" , "" , "" , "http://example.org/example.com/" }, |
| 724 | {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }); |
| 725 | |
| 726 | // This behavior matches Chrome and Firefox, but not WebKit using URL::parse. |
| 727 | // The behavior of URL::parse is clearly wrong because reparsing file://path would make path the host. |
| 728 | // The spec is unclear. |
| 729 | checkURLDifferences("file:path" , |
| 730 | {"file" , "" , "" , "" , 0, "/path" , "" , "" , "file:///path" }, |
| 731 | {"file" , "" , "" , "" , 0, "path" , "" , "" , "file://path" }); |
| 732 | checkURLDifferences("file:pAtH" , |
| 733 | {"file" , "" , "" , "" , 0, "/pAtH" , "" , "" , "file:///pAtH" }, |
| 734 | {"file" , "" , "" , "" , 0, "pAtH" , "" , "" , "file://pAtH" }); |
| 735 | checkURLDifferences("file:pAtH/" , |
| 736 | {"file" , "" , "" , "" , 0, "/pAtH/" , "" , "" , "file:///pAtH/" }, |
| 737 | {"file" , "" , "" , "" , 0, "pAtH/" , "" , "" , "file://pAtH/" }); |
| 738 | checkURLDifferences("http://example.com%A0" , |
| 739 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://example.com%A0" }, |
| 740 | {"http" , "" , "" , "example.com%a0" , 0, "/" , "" , "" , "http://example.com%a0/" }); |
| 741 | checkURLDifferences("http://%E2%98%83" , |
| 742 | {"http" , "" , "" , "xn--n3h" , 0, "/" , "" , "" , "http://xn--n3h/" }, |
| 743 | {"http" , "" , "" , "%e2%98%83" , 0, "/" , "" , "" , "http://%e2%98%83/" }); |
| 744 | checkURLDifferences("http://host%73" , |
| 745 | {"http" , "" , "" , "hosts" , 0, "/" , "" , "" , "http://hosts/" }, |
| 746 | {"http" , "" , "" , "host%73" , 0, "/" , "" , "" , "http://host%73/" }); |
| 747 | checkURLDifferences("http://host%53" , |
| 748 | {"http" , "" , "" , "hosts" , 0, "/" , "" , "" , "http://hosts/" }, |
| 749 | {"http" , "" , "" , "host%53" , 0, "/" , "" , "" , "http://host%53/" }); |
| 750 | checkURLDifferences("http://%" , |
| 751 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://%" }, |
| 752 | {"http" , "" , "" , "%" , 0, "/" , "" , "" , "http://%/" }); |
| 753 | checkURLDifferences("http://%7" , |
| 754 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://%7" }, |
| 755 | {"http" , "" , "" , "%7" , 0, "/" , "" , "" , "http://%7/" }); |
| 756 | checkURLDifferences("http://%7s" , |
| 757 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://%7s" }, |
| 758 | {"http" , "" , "" , "%7s" , 0, "/" , "" , "" , "http://%7s/" }); |
| 759 | checkURLDifferences("http://%73" , |
| 760 | {"http" , "" , "" , "s" , 0, "/" , "" , "" , "http://s/" }, |
| 761 | {"http" , "" , "" , "%73" , 0, "/" , "" , "" , "http://%73/" }); |
| 762 | checkURLDifferences("http://abcdefg%" , |
| 763 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://abcdefg%" }, |
| 764 | {"http" , "" , "" , "abcdefg%" , 0, "/" , "" , "" , "http://abcdefg%/" }); |
| 765 | checkURLDifferences("http://abcd%7Xefg" , |
| 766 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://abcd%7Xefg" }, |
| 767 | {"http" , "" , "" , "abcd%7xefg" , 0, "/" , "" , "" , "http://abcd%7xefg/" }); |
| 768 | |
| 769 | |
| 770 | // URLParser matches Chrome and the spec, but not URL::parse or Firefox. |
| 771 | checkURLDifferences(utf16String(u"http://0Xc0.0250.01" ), |
| 772 | {"http" , "" , "" , "192.168.0.1" , 0, "/" , "" , "" , "http://192.168.0.1/" }, |
| 773 | {"http" , "" , "" , "0xc0.0250.01" , 0, "/" , "" , "" , "http://0xc0.0250.01/" }); |
| 774 | |
| 775 | checkURL("http://host/path%2e.%2E" , {"http" , "" , "" , "host" , 0, "/path%2e.%2E" , "" , "" , "http://host/path%2e.%2E" }); |
| 776 | |
| 777 | checkRelativeURLDifferences(utf16String(u"http://foo:💩@example.com/bar" ), "http://other.com/" , |
| 778 | {"http" , "foo" , utf16String(u"💩" ), "example.com" , 0, "/bar" , "" , "" , "http://foo:%F0%9F%92%A9@example.com/bar" }, |
| 779 | {"" , "" , "" , "" , 0, "" , "" , "" , utf16String(u"http://foo:💩@example.com/bar" )}, testTabsValueForSurrogatePairs); |
| 780 | checkRelativeURLDifferences("http://&a:foo(b]c@d:2/" , "http://example.org/foo/bar" , |
| 781 | {"http" , "&a" , "foo(b]c" , "d" , 2, "/" , "" , "" , "http://&a:foo(b%5Dc@d:2/" }, |
| 782 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://&a:foo(b]c@d:2/" }); |
| 783 | checkRelativeURLDifferences("http://`{}:`{}@h/`{}?`{}" , "http://doesnotmatter/" , |
| 784 | {"http" , "`{}" , "`{}" , "h" , 0, "/%60%7B%7D" , "`{}" , "" , "http://%60%7B%7D:%60%7B%7D@h/%60%7B%7D?`{}" }, |
| 785 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://`{}:`{}@h/`{}?`{}" }); |
| 786 | checkURLDifferences("http://[0:f::f::f]" , |
| 787 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[0:f::f::f]" }, |
| 788 | {"http" , "" , "" , "[0:f::f::f]" , 0, "/" , "" , "" , "http://[0:f::f::f]/" }); |
| 789 | checkURLDifferences("http://123" , |
| 790 | {"http" , "" , "" , "0.0.0.123" , 0, "/" , "" , "" , "http://0.0.0.123/" }, |
| 791 | {"http" , "" , "" , "123" , 0, "/" , "" , "" , "http://123/" }); |
| 792 | checkURLDifferences("http://123.234/" , |
| 793 | {"http" , "" , "" , "123.0.0.234" , 0, "/" , "" , "" , "http://123.0.0.234/" }, |
| 794 | {"http" , "" , "" , "123.234" , 0, "/" , "" , "" , "http://123.234/" }); |
| 795 | checkURLDifferences("http://123.234.012" , |
| 796 | {"http" , "" , "" , "123.234.0.10" , 0, "/" , "" , "" , "http://123.234.0.10/" }, |
| 797 | {"http" , "" , "" , "123.234.012" , 0, "/" , "" , "" , "http://123.234.012/" }); |
| 798 | checkURLDifferences("http://123.234.12" , |
| 799 | {"http" , "" , "" , "123.234.0.12" , 0, "/" , "" , "" , "http://123.234.0.12/" }, |
| 800 | {"http" , "" , "" , "123.234.12" , 0, "/" , "" , "" , "http://123.234.12/" }); |
| 801 | checkRelativeURLDifferences("file:c:\\foo\\bar.html" , "file:///tmp/mock/path" , |
| 802 | {"file" , "" , "" , "" , 0, "/c:/foo/bar.html" , "" , "" , "file:///c:/foo/bar.html" }, |
| 803 | {"file" , "" , "" , "" , 0, "/tmp/mock/c:/foo/bar.html" , "" , "" , "file:///tmp/mock/c:/foo/bar.html" }); |
| 804 | checkRelativeURLDifferences(" File:c|////foo\\bar.html" , "file:///tmp/mock/path" , |
| 805 | {"file" , "" , "" , "" , 0, "/c:////foo/bar.html" , "" , "" , "file:///c:////foo/bar.html" }, |
| 806 | {"file" , "" , "" , "" , 0, "/tmp/mock/c|////foo/bar.html" , "" , "" , "file:///tmp/mock/c|////foo/bar.html" }); |
| 807 | checkRelativeURLDifferences(" Fil\t\n\te\n\t\n:\t\n\tc\t\n\t|\n\t\n/\t\n\t/\n\t\n//foo\\bar.html" , "file:///tmp/mock/path" , |
| 808 | {"file" , "" , "" , "" , 0, "/c:////foo/bar.html" , "" , "" , "file:///c:////foo/bar.html" }, |
| 809 | {"file" , "" , "" , "" , 0, "/tmp/mock/c|////foo/bar.html" , "" , "" , "file:///tmp/mock/c|////foo/bar.html" }); |
| 810 | checkRelativeURLDifferences("C|/foo/bar" , "file:///tmp/mock/path" , |
| 811 | {"file" , "" , "" , "" , 0, "/C:/foo/bar" , "" , "" , "file:///C:/foo/bar" }, |
| 812 | {"file" , "" , "" , "" , 0, "/tmp/mock/C|/foo/bar" , "" , "" , "file:///tmp/mock/C|/foo/bar" }); |
| 813 | checkRelativeURLDifferences("/C|/foo/bar" , "file:///tmp/mock/path" , |
| 814 | {"file" , "" , "" , "" , 0, "/C:/foo/bar" , "" , "" , "file:///C:/foo/bar" }, |
| 815 | {"file" , "" , "" , "" , 0, "/C|/foo/bar" , "" , "" , "file:///C|/foo/bar" }); |
| 816 | checkRelativeURLDifferences("https://@test@test@example:800/" , "http://doesnotmatter/" , |
| 817 | {"https" , "@test@test" , "" , "example" , 800, "/" , "" , "" , "https://%40test%40test@example:800/" }, |
| 818 | {"" , "" , "" , "" , 0, "" , "" , "" , "https://@test@test@example:800/" }); |
| 819 | checkRelativeURLDifferences("https://@test@test@example:800/path@end" , "http://doesnotmatter/" , |
| 820 | {"https" , "@test@test" , "" , "example" , 800, "/path@end" , "" , "" , "https://%40test%40test@example:800/path@end" }, |
| 821 | {"" , "" , "" , "" , 0, "" , "" , "" , "https://@test@test@example:800/path@end" }); |
| 822 | checkURLDifferences("notspecial://@test@test@example:800/path@end" , |
| 823 | {"notspecial" , "@test@test" , "" , "example" , 800, "/path@end" , "" , "" , "notspecial://%40test%40test@example:800/path@end" }, |
| 824 | {"" , "" , "" , "" , 0, "" , "" , "" , "notspecial://@test@test@example:800/path@end" }); |
| 825 | checkURLDifferences("notspecial://@test@test@example:800\\path@end" , |
| 826 | {"notspecial" , "@test@test@example" , "800\\path" , "end" , 0, "" , "" , "" , "notspecial://%40test%40test%40example:800%5Cpath@end" }, |
| 827 | {"" , "" , "" , "" , 0, "" , "" , "" , "notspecial://@test@test@example:800\\path@end" }); |
| 828 | checkURLDifferences("http://%48OsT" , |
| 829 | {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }, |
| 830 | {"http" , "" , "" , "%48ost" , 0, "/" , "" , "" , "http://%48ost/" }); |
| 831 | checkURLDifferences("http://h%4FsT" , |
| 832 | {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }, |
| 833 | {"http" , "" , "" , "h%4fst" , 0, "/" , "" , "" , "http://h%4fst/" }); |
| 834 | checkURLDifferences("http://h%4fsT" , |
| 835 | {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }, |
| 836 | {"http" , "" , "" , "h%4fst" , 0, "/" , "" , "" , "http://h%4fst/" }); |
| 837 | checkURLDifferences("http://h%6fsT" , |
| 838 | {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }, |
| 839 | {"http" , "" , "" , "h%6fst" , 0, "/" , "" , "" , "http://h%6fst/" }); |
| 840 | checkURLDifferences("http://host/`" , |
| 841 | {"http" , "" , "" , "host" , 0, "/%60" , "" , "" , "http://host/%60" }, |
| 842 | {"http" , "" , "" , "host" , 0, "/`" , "" , "" , "http://host/`" }); |
| 843 | checkURLDifferences("http://://" , |
| 844 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://://" }, |
| 845 | {"http" , "" , "" , "" , 0, "//" , "" , "" , "http://://" }); |
| 846 | checkURLDifferences("http://:123?" , |
| 847 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://:123?" }, |
| 848 | {"http" , "" , "" , "" , 123, "/" , "" , "" , "http://:123/?" }); |
| 849 | checkURLDifferences("http:/:" , |
| 850 | {"" , "" , "" , "" , 0, "" , "" , "" , "http:/:" }, |
| 851 | {"http" , "" , "" , "" , 0, "/" , "" , "" , "http://:/" }); |
| 852 | checkURLDifferences("asdf://:" , |
| 853 | {"" , "" , "" , "" , 0, "" , "" , "" , "asdf://:" }, |
| 854 | {"asdf" , "" , "" , "" , 0, "" , "" , "" , "asdf://:" }); |
| 855 | checkURLDifferences("http://:" , |
| 856 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://:" }, |
| 857 | {"http" , "" , "" , "" , 0, "/" , "" , "" , "http://:/" }); |
| 858 | checkURLDifferences("http:##foo" , |
| 859 | {"" , "" , "" , "" , 0, "" , "" , "" , "http:##foo" }, |
| 860 | {"http" , "" , "" , "" , 0, "/" , "" , "#foo" , "http:/##foo" }); |
| 861 | checkURLDifferences("http:??bar" , |
| 862 | {"" , "" , "" , "" , 0, "" , "" , "" , "http:??bar" }, |
| 863 | {"http" , "" , "" , "" , 0, "/" , "?bar" , "" , "http:/??bar" }); |
| 864 | checkURL("asdf:##foo" , {"asdf" , "" , "" , "" , 0, "" , "" , "#foo" , "asdf:##foo" }); |
| 865 | checkURL("asdf:??bar" , {"asdf" , "" , "" , "" , 0, "" , "?bar" , "" , "asdf:??bar" }); |
| 866 | checkRelativeURLDifferences("//C|/foo/bar" , "file:///tmp/mock/path" , |
| 867 | {"file" , "" , "" , "" , 0, "/C:/foo/bar" , "" , "" , "file:///C:/foo/bar" }, |
| 868 | {"" , "" , "" , "" , 0, "" , "" , "" , "//C|/foo/bar" }); |
| 869 | checkRelativeURLDifferences("//C:/foo/bar" , "file:///tmp/mock/path" , |
| 870 | {"file" , "" , "" , "" , 0, "/C:/foo/bar" , "" , "" , "file:///C:/foo/bar" }, |
| 871 | {"file" , "" , "" , "c" , 0, "/foo/bar" , "" , "" , "file://c/foo/bar" }); |
| 872 | checkRelativeURLDifferences("//C|?foo/bar" , "file:///tmp/mock/path" , |
| 873 | {"file" , "" , "" , "" , 0, "/C:/" , "foo/bar" , "" , "file:///C:/?foo/bar" }, |
| 874 | {"" , "" , "" , "" , 0, "" , "" , "" , "//C|?foo/bar" }); |
| 875 | checkRelativeURLDifferences("//C|#foo/bar" , "file:///tmp/mock/path" , |
| 876 | {"file" , "" , "" , "" , 0, "/C:/" , "" , "foo/bar" , "file:///C:/#foo/bar" }, |
| 877 | {"" , "" , "" , "" , 0, "" , "" , "" , "//C|#foo/bar" }); |
| 878 | checkURLDifferences("http://0xFFFFFfFF/" , |
| 879 | {"http" , "" , "" , "255.255.255.255" , 0, "/" , "" , "" , "http://255.255.255.255/" }, |
| 880 | {"http" , "" , "" , "0xffffffff" , 0, "/" , "" , "" , "http://0xffffffff/" }); |
| 881 | checkURLDifferences("http://0000000000000000037777777777/" , |
| 882 | {"http" , "" , "" , "255.255.255.255" , 0, "/" , "" , "" , "http://255.255.255.255/" }, |
| 883 | {"http" , "" , "" , "0000000000000000037777777777" , 0, "/" , "" , "" , "http://0000000000000000037777777777/" }); |
| 884 | checkURLDifferences("http://4294967295/" , |
| 885 | {"http" , "" , "" , "255.255.255.255" , 0, "/" , "" , "" , "http://255.255.255.255/" }, |
| 886 | {"http" , "" , "" , "4294967295" , 0, "/" , "" , "" , "http://4294967295/" }); |
| 887 | checkURLDifferences("http://256/" , |
| 888 | {"http" , "" , "" , "0.0.1.0" , 0, "/" , "" , "" , "http://0.0.1.0/" }, |
| 889 | {"http" , "" , "" , "256" , 0, "/" , "" , "" , "http://256/" }); |
| 890 | checkURLDifferences("http://256./" , |
| 891 | {"http" , "" , "" , "0.0.1.0" , 0, "/" , "" , "" , "http://0.0.1.0/" }, |
| 892 | {"http" , "" , "" , "256." , 0, "/" , "" , "" , "http://256./" }); |
| 893 | checkURLDifferences("http://123.256/" , |
| 894 | {"http" , "" , "" , "123.0.1.0" , 0, "/" , "" , "" , "http://123.0.1.0/" }, |
| 895 | {"http" , "" , "" , "123.256" , 0, "/" , "" , "" , "http://123.256/" }); |
| 896 | checkURLDifferences("http://127.%.0.1/" , |
| 897 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://127.%.0.1/" }, |
| 898 | {"http" , "" , "" , "127.%.0.1" , 0, "/" , "" , "" , "http://127.%.0.1/" }); |
| 899 | checkURLDifferences("http://[1:2:3:4:5:6:7:8:]/" , |
| 900 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[1:2:3:4:5:6:7:8:]/" }, |
| 901 | {"http" , "" , "" , "[1:2:3:4:5:6:7:8:]" , 0, "/" , "" , "" , "http://[1:2:3:4:5:6:7:8:]/" }); |
| 902 | checkURLDifferences("http://[:2:3:4:5:6:7:8:]/" , |
| 903 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[:2:3:4:5:6:7:8:]/" }, |
| 904 | {"http" , "" , "" , "[:2:3:4:5:6:7:8:]" , 0, "/" , "" , "" , "http://[:2:3:4:5:6:7:8:]/" }); |
| 905 | checkURLDifferences("http://[1:2:3:4:5:6:7::]/" , |
| 906 | {"http" , "" , "" , "[1:2:3:4:5:6:7:0]" , 0, "/" , "" , "" , "http://[1:2:3:4:5:6:7:0]/" }, |
| 907 | {"http" , "" , "" , "[1:2:3:4:5:6:7::]" , 0, "/" , "" , "" , "http://[1:2:3:4:5:6:7::]/" }); |
| 908 | checkURLDifferences("http://[1:2:3:4:5:6:7:::]/" , |
| 909 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[1:2:3:4:5:6:7:::]/" }, |
| 910 | {"http" , "" , "" , "[1:2:3:4:5:6:7:::]" , 0, "/" , "" , "" , "http://[1:2:3:4:5:6:7:::]/" }); |
| 911 | checkURLDifferences("http://127.0.0.1~/" , |
| 912 | {"http" , "" , "" , "127.0.0.1~" , 0, "/" , "" , "" , "http://127.0.0.1~/" }, |
| 913 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://127.0.0.1~/" }); |
| 914 | checkURLDifferences("http://127.0.1~/" , |
| 915 | {"http" , "" , "" , "127.0.1~" , 0, "/" , "" , "" , "http://127.0.1~/" }, |
| 916 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://127.0.1~/" }); |
| 917 | checkURLDifferences("http://127.0.1./" , |
| 918 | {"http" , "" , "" , "127.0.0.1" , 0, "/" , "" , "" , "http://127.0.0.1/" }, |
| 919 | {"http" , "" , "" , "127.0.1." , 0, "/" , "" , "" , "http://127.0.1./" }); |
| 920 | checkURLDifferences("http://127.0.1.~/" , |
| 921 | {"http" , "" , "" , "127.0.1.~" , 0, "/" , "" , "" , "http://127.0.1.~/" }, |
| 922 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://127.0.1.~/" }); |
| 923 | checkURLDifferences("http://127.0.1.~" , |
| 924 | {"http" , "" , "" , "127.0.1.~" , 0, "/" , "" , "" , "http://127.0.1.~/" }, |
| 925 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://127.0.1.~" }); |
| 926 | checkRelativeURLDifferences("http://f:000/c" , "http://example.org/foo/bar" , |
| 927 | {"http" , "" , "" , "f" , 0, "/c" , "" , "" , "http://f:0/c" }, |
| 928 | {"http" , "" , "" , "f" , 0, "/c" , "" , "" , "http://f:000/c" }); |
| 929 | checkRelativeURLDifferences("http://f:010/c" , "http://example.org/foo/bar" , |
| 930 | {"http" , "" , "" , "f" , 10, "/c" , "" , "" , "http://f:10/c" }, |
| 931 | {"http" , "" , "" , "f" , 10, "/c" , "" , "" , "http://f:010/c" }); |
| 932 | checkURL("notspecial://HoSt" , {"notspecial" , "" , "" , "HoSt" , 0, "" , "" , "" , "notspecial://HoSt" }); |
| 933 | checkURL("notspecial://H%6FSt" , {"notspecial" , "" , "" , "H%6FSt" , 0, "" , "" , "" , "notspecial://H%6FSt" }); |
| 934 | checkURL("notspecial://H%4fSt" , {"notspecial" , "" , "" , "H%4fSt" , 0, "" , "" , "" , "notspecial://H%4fSt" }); |
| 935 | checkURLDifferences(utf16String(u"notspecial://H😍ßt" ), |
| 936 | {"notspecial" , "" , "" , "H%F0%9F%98%8D%C3%9Ft" , 0, "" , "" , "" , "notspecial://H%F0%9F%98%8D%C3%9Ft" }, |
| 937 | {"notspecial" , "" , "" , "xn--hsst-qc83c" , 0, "" , "" , "" , "notspecial://xn--hsst-qc83c" }, testTabsValueForSurrogatePairs); |
| 938 | checkURLDifferences("http://[ffff:aaaa:cccc:eeee:bbbb:dddd:255.255.255.255]/" , |
| 939 | {"http" , "" , "" , "[ffff:aaaa:cccc:eeee:bbbb:dddd:ffff:ffff]" , 0, "/" , "" , "" , "http://[ffff:aaaa:cccc:eeee:bbbb:dddd:ffff:ffff]/" }, |
| 940 | {"http" , "" , "" , "[ffff:aaaa:cccc:eeee:bbbb:dddd:255.255.255.255]" , 0, "/" , "" , "" , "http://[ffff:aaaa:cccc:eeee:bbbb:dddd:255.255.255.255]/" }, TestTabs::No); |
| 941 | checkURLDifferences("http://[::123.234.12.210]/" , |
| 942 | {"http" , "" , "" , "[::7bea:cd2]" , 0, "/" , "" , "" , "http://[::7bea:cd2]/" }, |
| 943 | {"http" , "" , "" , "[::123.234.12.210]" , 0, "/" , "" , "" , "http://[::123.234.12.210]/" }); |
| 944 | checkURLDifferences("http://[::a:255.255.255.255]/" , |
| 945 | {"http" , "" , "" , "[::a:ffff:ffff]" , 0, "/" , "" , "" , "http://[::a:ffff:ffff]/" }, |
| 946 | {"http" , "" , "" , "[::a:255.255.255.255]" , 0, "/" , "" , "" , "http://[::a:255.255.255.255]/" }); |
| 947 | checkURLDifferences("http://[::0.00.255.255]/" , |
| 948 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[::0.00.255.255]/" }, |
| 949 | {"http" , "" , "" , "[::0.00.255.255]" , 0, "/" , "" , "" , "http://[::0.00.255.255]/" }); |
| 950 | checkURLDifferences("http://[::0.0.255.255]/" , |
| 951 | {"http" , "" , "" , "[::ffff]" , 0, "/" , "" , "" , "http://[::ffff]/" }, |
| 952 | {"http" , "" , "" , "[::0.0.255.255]" , 0, "/" , "" , "" , "http://[::0.0.255.255]/" }); |
| 953 | checkURLDifferences("http://[::0:1.0.255.255]/" , |
| 954 | {"http" , "" , "" , "[::100:ffff]" , 0, "/" , "" , "" , "http://[::100:ffff]/" }, |
| 955 | {"http" , "" , "" , "[::0:1.0.255.255]" , 0, "/" , "" , "" , "http://[::0:1.0.255.255]/" }); |
| 956 | checkURLDifferences("http://[::A:1.0.255.255]/" , |
| 957 | {"http" , "" , "" , "[::a:100:ffff]" , 0, "/" , "" , "" , "http://[::a:100:ffff]/" }, |
| 958 | {"http" , "" , "" , "[::a:1.0.255.255]" , 0, "/" , "" , "" , "http://[::a:1.0.255.255]/" }); |
| 959 | checkURLDifferences("http://[:127.0.0.1]" , |
| 960 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[:127.0.0.1]" }, |
| 961 | {"http" , "" , "" , "[:127.0.0.1]" , 0, "/" , "" , "" , "http://[:127.0.0.1]/" }); |
| 962 | checkURLDifferences("http://[127.0.0.1]" , |
| 963 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[127.0.0.1]" }, |
| 964 | {"http" , "" , "" , "[127.0.0.1]" , 0, "/" , "" , "" , "http://[127.0.0.1]/" }); |
| 965 | checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.1]" , |
| 966 | {"http" , "" , "" , "[a:b:c:d:e:f:7f00:1]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f:7f00:1]/" }, |
| 967 | {"http" , "" , "" , "[a:b:c:d:e:f:127.0.0.1]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f:127.0.0.1]/" }); |
| 968 | checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.101]" , |
| 969 | {"http" , "" , "" , "[a:b:c:d:e:f:7f00:65]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f:7f00:65]/" }, |
| 970 | {"http" , "" , "" , "[a:b:c:d:e:f:127.0.0.101]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f:127.0.0.101]/" }); |
| 971 | checkURLDifferences("http://[::a:b:c:d:e:f:127.0.0.1]" , |
| 972 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[::a:b:c:d:e:f:127.0.0.1]" }, |
| 973 | {"http" , "" , "" , "[::a:b:c:d:e:f:127.0.0.1]" , 0, "/" , "" , "" , "http://[::a:b:c:d:e:f:127.0.0.1]/" }); |
| 974 | checkURLDifferences("http://[a:b::c:d:e:f:127.0.0.1]" , |
| 975 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[a:b::c:d:e:f:127.0.0.1]" }, |
| 976 | {"http" , "" , "" , "[a:b::c:d:e:f:127.0.0.1]" , 0, "/" , "" , "" , "http://[a:b::c:d:e:f:127.0.0.1]/" }); |
| 977 | checkURLDifferences("http://[a:b:c:d:e:127.0.0.1]" , |
| 978 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[a:b:c:d:e:127.0.0.1]" }, |
| 979 | {"http" , "" , "" , "[a:b:c:d:e:127.0.0.1]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:127.0.0.1]/" }); |
| 980 | checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.0.1]" , |
| 981 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[a:b:c:d:e:f:127.0.0.0.1]" }, |
| 982 | {"http" , "" , "" , "[a:b:c:d:e:f:127.0.0.0.1]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f:127.0.0.0.1]/" }); |
| 983 | checkURLDifferences("http://[a:b:c:d:e:f:127.0.1]" , |
| 984 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[a:b:c:d:e:f:127.0.1]" }, |
| 985 | {"http" , "" , "" , "[a:b:c:d:e:f:127.0.1]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f:127.0.1]/" }); |
| 986 | checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.011]" , // Chrome treats this as octal, Firefox and the spec fail |
| 987 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[a:b:c:d:e:f:127.0.0.011]" }, |
| 988 | {"http" , "" , "" , "[a:b:c:d:e:f:127.0.0.011]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f:127.0.0.011]/" }); |
| 989 | checkURLDifferences("http://[a:b:c:d:e:f:127.0.00.1]" , |
| 990 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[a:b:c:d:e:f:127.0.00.1]" }, |
| 991 | {"http" , "" , "" , "[a:b:c:d:e:f:127.0.00.1]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f:127.0.00.1]/" }); |
| 992 | checkURLDifferences("http://[a:b:c:d:e:f:127.0.0.1.]" , |
| 993 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[a:b:c:d:e:f:127.0.0.1.]" }, |
| 994 | {"http" , "" , "" , "[a:b:c:d:e:f:127.0.0.1.]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f:127.0.0.1.]/" }); |
| 995 | checkURLDifferences("http://[a:b:c:d:e:f:127.0..0.1]" , |
| 996 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[a:b:c:d:e:f:127.0..0.1]" }, |
| 997 | {"http" , "" , "" , "[a:b:c:d:e:f:127.0..0.1]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f:127.0..0.1]/" }); |
| 998 | checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.1]" , |
| 999 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[a:b:c:d:e:f::127.0.0.1]" }, |
| 1000 | {"http" , "" , "" , "[a:b:c:d:e:f::127.0.0.1]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f::127.0.0.1]/" }); |
| 1001 | checkURLDifferences("http://[a:b:c:d:e::127.0.0.1]" , |
| 1002 | {"http" , "" , "" , "[a:b:c:d:e:0:7f00:1]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:0:7f00:1]/" }, |
| 1003 | {"http" , "" , "" , "[a:b:c:d:e::127.0.0.1]" , 0, "/" , "" , "" , "http://[a:b:c:d:e::127.0.0.1]/" }); |
| 1004 | checkURLDifferences("http://[a:b:c:d::e:127.0.0.1]" , |
| 1005 | {"http" , "" , "" , "[a:b:c:d:0:e:7f00:1]" , 0, "/" , "" , "" , "http://[a:b:c:d:0:e:7f00:1]/" }, |
| 1006 | {"http" , "" , "" , "[a:b:c:d::e:127.0.0.1]" , 0, "/" , "" , "" , "http://[a:b:c:d::e:127.0.0.1]/" }); |
| 1007 | checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.]" , |
| 1008 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[a:b:c:d:e:f::127.0.0.]" }, |
| 1009 | {"http" , "" , "" , "[a:b:c:d:e:f::127.0.0.]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f::127.0.0.]/" }); |
| 1010 | checkURLDifferences("http://[a:b:c:d:e:f::127.0.0.256]" , |
| 1011 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://[a:b:c:d:e:f::127.0.0.256]" }, |
| 1012 | {"http" , "" , "" , "[a:b:c:d:e:f::127.0.0.256]" , 0, "/" , "" , "" , "http://[a:b:c:d:e:f::127.0.0.256]/" }); |
| 1013 | checkURLDifferences("http://123456" , {"http" , "" , "" , "0.1.226.64" , 0, "/" , "" , "" , "http://0.1.226.64/" }, {"http" , "" , "" , "123456" , 0, "/" , "" , "" , "http://123456/" }); |
| 1014 | checkURL("asdf://123456" , {"asdf" , "" , "" , "123456" , 0, "" , "" , "" , "asdf://123456" }); |
| 1015 | checkURLDifferences("http://[0:0:0:0:a:b:c:d]" , |
| 1016 | {"http" , "" , "" , "[::a:b:c:d]" , 0, "/" , "" , "" , "http://[::a:b:c:d]/" }, |
| 1017 | {"http" , "" , "" , "[0:0:0:0:a:b:c:d]" , 0, "/" , "" , "" , "http://[0:0:0:0:a:b:c:d]/" }); |
| 1018 | checkURLDifferences("asdf://[0:0:0:0:a:b:c:d]" , |
| 1019 | {"asdf" , "" , "" , "[::a:b:c:d]" , 0, "" , "" , "" , "asdf://[::a:b:c:d]" }, |
| 1020 | {"asdf" , "" , "" , "[0:0:0:0:a:b:c:d]" , 0, "" , "" , "" , "asdf://[0:0:0:0:a:b:c:d]" }, TestTabs::No); |
| 1021 | shouldFail("a://%:a" ); |
| 1022 | checkURL("a://%:/" , {"a" , "" , "" , "%" , 0, "/" , "" , "" , "a://%/" }); |
| 1023 | checkURL("a://%:" , {"a" , "" , "" , "%" , 0, "" , "" , "" , "a://%" }); |
| 1024 | checkURL("a://%:1/" , {"a" , "" , "" , "%" , 1, "/" , "" , "" , "a://%:1/" }); |
| 1025 | checkURLDifferences("http://%:" , |
| 1026 | {"" , "" , "" , "" , 0, "" , "" , "" , "http://%:" }, |
| 1027 | {"http" , "" , "" , "%" , 0, "/" , "" , "" , "http://%/" }); |
| 1028 | checkURL("a://123456" , {"a" , "" , "" , "123456" , 0, "" , "" , "" , "a://123456" }); |
| 1029 | checkURL("a://123456:7" , {"a" , "" , "" , "123456" , 7, "" , "" , "" , "a://123456:7" }); |
| 1030 | checkURL("a://123456:7/" , {"a" , "" , "" , "123456" , 7, "/" , "" , "" , "a://123456:7/" }); |
| 1031 | checkURL("a://A" , {"a" , "" , "" , "A" , 0, "" , "" , "" , "a://A" }); |
| 1032 | checkURL("a://A:2" , {"a" , "" , "" , "A" , 2, "" , "" , "" , "a://A:2" }); |
| 1033 | checkURL("a://A:2/" , {"a" , "" , "" , "A" , 2, "/" , "" , "" , "a://A:2/" }); |
| 1034 | checkURLDifferences(u8"asd://ß" , |
| 1035 | {"asd" , "" , "" , "%C3%83%C2%9F" , 0, "" , "" , "" , "asd://%C3%83%C2%9F" }, |
| 1036 | {"" , "" , "" , "" , 0, "" , "" , "" , "about:blank" }, TestTabs::No); |
| 1037 | checkURLDifferences(u8"asd://ß:4" , |
| 1038 | {"asd" , "" , "" , "%C3%83%C2%9F" , 4, "" , "" , "" , "asd://%C3%83%C2%9F:4" }, |
| 1039 | {"" , "" , "" , "" , 0, "" , "" , "" , "about:blank" }, TestTabs::No); |
| 1040 | checkURLDifferences(u8"asd://ß:4/" , |
| 1041 | {"asd" , "" , "" , "%C3%83%C2%9F" , 4, "/" , "" , "" , "asd://%C3%83%C2%9F:4/" }, |
| 1042 | {"" , "" , "" , "" , 0, "" , "" , "" , "about:blank" }, TestTabs::No); |
| 1043 | checkURLDifferences("a://[A::b]:4" , |
| 1044 | {"a" , "" , "" , "[a::b]" , 4, "" , "" , "" , "a://[a::b]:4" }, |
| 1045 | {"a" , "" , "" , "[A::b]" , 4, "" , "" , "" , "a://[A::b]:4" }); |
| 1046 | shouldFail("http://[~]" ); |
| 1047 | shouldFail("a://[~]" ); |
| 1048 | checkRelativeURLDifferences("a://b" , "//[aBc]" , |
| 1049 | {"a" , "" , "" , "b" , 0, "" , "" , "" , "a://b" }, |
| 1050 | {"" , "" , "" , "" , 0, "" , "" , "" , "a://b" }); |
| 1051 | checkURL(utf16String(u"http://öbb.at" ), {"http" , "" , "" , "xn--bb-eka.at" , 0, "/" , "" , "" , "http://xn--bb-eka.at/" }); |
| 1052 | checkURL(utf16String(u"http://ÖBB.at" ), {"http" , "" , "" , "xn--bb-eka.at" , 0, "/" , "" , "" , "http://xn--bb-eka.at/" }); |
| 1053 | checkURL(utf16String(u"http://√.com" ), {"http" , "" , "" , "xn--19g.com" , 0, "/" , "" , "" , "http://xn--19g.com/" }); |
| 1054 | checkURLDifferences(utf16String(u"http://faß.de" ), |
| 1055 | {"http" , "" , "" , "xn--fa-hia.de" , 0, "/" , "" , "" , "http://xn--fa-hia.de/" }, |
| 1056 | {"http" , "" , "" , "fass.de" , 0, "/" , "" , "" , "http://fass.de/" }); |
| 1057 | checkURL(utf16String(u"http://ԛәлп.com" ), {"http" , "" , "" , "xn--k1ai47bhi.com" , 0, "/" , "" , "" , "http://xn--k1ai47bhi.com/" }); |
| 1058 | checkURLDifferences(utf16String(u"http://Ⱥbby.com" ), |
| 1059 | {"http" , "" , "" , "xn--bby-iy0b.com" , 0, "/" , "" , "" , "http://xn--bby-iy0b.com/" }, |
| 1060 | {"http" , "" , "" , "xn--bby-spb.com" , 0, "/" , "" , "" , "http://xn--bby-spb.com/" }); |
| 1061 | checkURLDifferences(utf16String(u"http://\u2132" ), |
| 1062 | {"" , "" , "" , "" , 0, "" , "" , "" , utf16String(u"http://Ⅎ" )}, |
| 1063 | {"http" , "" , "" , "xn--f3g" , 0, "/" , "" , "" , "http://xn--f3g/" }); |
| 1064 | checkURLDifferences(utf16String(u"http://\u05D9\u05B4\u05D5\u05D0\u05B8/" ), |
| 1065 | {"http" , "" , "" , "xn--cdbi5etas" , 0, "/" , "" , "" , "http://xn--cdbi5etas/" }, |
| 1066 | {"" , "" , "" , "" , 0, "" , "" , "" , "about:blank" }, TestTabs::No); |
| 1067 | checkURLDifferences(utf16String(u"http://bidirectional\u0786\u07AE\u0782\u07B0\u0795\u07A9\u0793\u07A6\u0783\u07AA/" ), |
| 1068 | {"" , "" , "" , "" , 0, "" , "" , "" , utf16String(u"http://bidirectionalކޮންޕީޓަރު/" )}, |
| 1069 | {"" , "" , "" , "" , 0, "" , "" , "" , "about:blank" }, TestTabs::No); |
| 1070 | checkURLDifferences(utf16String(u"http://contextj\u200D" ), |
| 1071 | {"" , "" , "" , "" , 0, "" , "" , "" , utf16String(u"http://contextj\u200D" )}, |
| 1072 | {"http" , "" , "" , "contextj" , 0, "/" , "" , "" , "http://contextj/" }); |
| 1073 | checkURL(utf16String(u"http://contexto\u30FB" ), {"http" , "" , "" , "xn--contexto-wg5g" , 0, "/" , "" , "" , "http://xn--contexto-wg5g/" }); |
| 1074 | checkURLDifferences(utf16String(u"http://\u321D\u321E/" ), |
| 1075 | {"http" , "" , "" , "xn--()()-bs0sc174agx4b" , 0, "/" , "" , "" , "http://xn--()()-bs0sc174agx4b/" }, |
| 1076 | {"http" , "" , "" , "xn--5mkc" , 0, "/" , "" , "" , "http://xn--5mkc/" }); |
| 1077 | } |
| 1078 | |
| 1079 | TEST_F(WTF_URLParser, DefaultPort) |
| 1080 | { |
| 1081 | checkURL("FtP://host:21/" , {"ftp" , "" , "" , "host" , 0, "/" , "" , "" , "ftp://host/" }); |
| 1082 | checkURL("ftp://host:21/" , {"ftp" , "" , "" , "host" , 0, "/" , "" , "" , "ftp://host/" }); |
| 1083 | checkURL("f\ttp://host:21/" , {"ftp" , "" , "" , "host" , 0, "/" , "" , "" , "ftp://host/" }); |
| 1084 | checkURL("f\ttp://host\t:21/" , {"ftp" , "" , "" , "host" , 0, "/" , "" , "" , "ftp://host/" }); |
| 1085 | checkURL("f\ttp://host:\t21/" , {"ftp" , "" , "" , "host" , 0, "/" , "" , "" , "ftp://host/" }); |
| 1086 | checkURL("f\ttp://host:2\t1/" , {"ftp" , "" , "" , "host" , 0, "/" , "" , "" , "ftp://host/" }); |
| 1087 | checkURL("f\ttp://host:21\t/" , {"ftp" , "" , "" , "host" , 0, "/" , "" , "" , "ftp://host/" }); |
| 1088 | checkURL("ftp://host\t:21/" , {"ftp" , "" , "" , "host" , 0, "/" , "" , "" , "ftp://host/" }); |
| 1089 | checkURL("ftp://host:\t21/" , {"ftp" , "" , "" , "host" , 0, "/" , "" , "" , "ftp://host/" }); |
| 1090 | checkURL("ftp://host:2\t1/" , {"ftp" , "" , "" , "host" , 0, "/" , "" , "" , "ftp://host/" }); |
| 1091 | checkURL("ftp://host:21\t/" , {"ftp" , "" , "" , "host" , 0, "/" , "" , "" , "ftp://host/" }); |
| 1092 | checkURL("ftp://host:22/" , {"ftp" , "" , "" , "host" , 22, "/" , "" , "" , "ftp://host:22/" }); |
| 1093 | checkURLDifferences("ftp://host:21" , |
| 1094 | {"ftp" , "" , "" , "host" , 0, "/" , "" , "" , "ftp://host/" }, |
| 1095 | {"ftp" , "" , "" , "host" , 0, "" , "" , "" , "ftp://host" }); |
| 1096 | checkURLDifferences("ftp://host:22" , |
| 1097 | {"ftp" , "" , "" , "host" , 22, "/" , "" , "" , "ftp://host:22/" }, |
| 1098 | {"ftp" , "" , "" , "host" , 22, "" , "" , "" , "ftp://host:22" }); |
| 1099 | |
| 1100 | checkURL("gOpHeR://host:70/" , {"gopher" , "" , "" , "host" , 0, "/" , "" , "" , "gopher://host/" }); |
| 1101 | checkURL("gopher://host:70/" , {"gopher" , "" , "" , "host" , 0, "/" , "" , "" , "gopher://host/" }); |
| 1102 | checkURL("gopher://host:71/" , {"gopher" , "" , "" , "host" , 71, "/" , "" , "" , "gopher://host:71/" }); |
| 1103 | // Spec, Chrome, Firefox, and URLParser have "/", URL::parse does not. |
| 1104 | // Spec, Chrome, URLParser, URL::parse recognize gopher default port, Firefox does not. |
| 1105 | checkURLDifferences("gopher://host:70" , |
| 1106 | {"gopher" , "" , "" , "host" , 0, "/" , "" , "" , "gopher://host/" }, |
| 1107 | {"gopher" , "" , "" , "host" , 0, "" , "" , "" , "gopher://host" }); |
| 1108 | checkURLDifferences("gopher://host:71" , |
| 1109 | {"gopher" , "" , "" , "host" , 71, "/" , "" , "" , "gopher://host:71/" }, |
| 1110 | {"gopher" , "" , "" , "host" , 71, "" , "" , "" , "gopher://host:71" }); |
| 1111 | |
| 1112 | checkURL("hTtP://host:80" , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 1113 | checkURL("http://host:80" , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 1114 | checkURL("http://host:80/" , {"http" , "" , "" , "host" , 0, "/" , "" , "" , "http://host/" }); |
| 1115 | checkURL("http://host:81" , {"http" , "" , "" , "host" , 81, "/" , "" , "" , "http://host:81/" }); |
| 1116 | checkURL("http://host:81/" , {"http" , "" , "" , "host" , 81, "/" , "" , "" , "http://host:81/" }); |
| 1117 | |
| 1118 | checkURL("hTtPs://host:443" , {"https" , "" , "" , "host" , 0, "/" , "" , "" , "https://host/" }); |
| 1119 | checkURL("https://host:443" , {"https" , "" , "" , "host" , 0, "/" , "" , "" , "https://host/" }); |
| 1120 | checkURL("https://host:443/" , {"https" , "" , "" , "host" , 0, "/" , "" , "" , "https://host/" }); |
| 1121 | checkURL("https://host:444" , {"https" , "" , "" , "host" , 444, "/" , "" , "" , "https://host:444/" }); |
| 1122 | checkURL("https://host:444/" , {"https" , "" , "" , "host" , 444, "/" , "" , "" , "https://host:444/" }); |
| 1123 | |
| 1124 | checkURL("wS://host:80/" , {"ws" , "" , "" , "host" , 0, "/" , "" , "" , "ws://host/" }); |
| 1125 | checkURL("ws://host:80/" , {"ws" , "" , "" , "host" , 0, "/" , "" , "" , "ws://host/" }); |
| 1126 | checkURL("ws://host:81/" , {"ws" , "" , "" , "host" , 81, "/" , "" , "" , "ws://host:81/" }); |
| 1127 | // URLParser matches Chrome and Firefox, but not URL::parse |
| 1128 | checkURLDifferences("ws://host:80" , |
| 1129 | {"ws" , "" , "" , "host" , 0, "/" , "" , "" , "ws://host/" }, |
| 1130 | {"ws" , "" , "" , "host" , 0, "" , "" , "" , "ws://host" }); |
| 1131 | checkURLDifferences("ws://host:81" , |
| 1132 | {"ws" , "" , "" , "host" , 81, "/" , "" , "" , "ws://host:81/" }, |
| 1133 | {"ws" , "" , "" , "host" , 81, "" , "" , "" , "ws://host:81" }); |
| 1134 | |
| 1135 | checkURL("WsS://host:443/" , {"wss" , "" , "" , "host" , 0, "/" , "" , "" , "wss://host/" }); |
| 1136 | checkURL("wss://host:443/" , {"wss" , "" , "" , "host" , 0, "/" , "" , "" , "wss://host/" }); |
| 1137 | checkURL("wss://host:444/" , {"wss" , "" , "" , "host" , 444, "/" , "" , "" , "wss://host:444/" }); |
| 1138 | // URLParser matches Chrome and Firefox, but not URL::parse |
| 1139 | checkURLDifferences("wss://host:443" , |
| 1140 | {"wss" , "" , "" , "host" , 0, "/" , "" , "" , "wss://host/" }, |
| 1141 | {"wss" , "" , "" , "host" , 0, "" , "" , "" , "wss://host" }); |
| 1142 | checkURLDifferences("wss://host:444" , |
| 1143 | {"wss" , "" , "" , "host" , 444, "/" , "" , "" , "wss://host:444/" }, |
| 1144 | {"wss" , "" , "" , "host" , 444, "" , "" , "" , "wss://host:444" }); |
| 1145 | |
| 1146 | checkURL("fTpS://host:990/" , {"ftps" , "" , "" , "host" , 990, "/" , "" , "" , "ftps://host:990/" }); |
| 1147 | checkURL("ftps://host:990/" , {"ftps" , "" , "" , "host" , 990, "/" , "" , "" , "ftps://host:990/" }); |
| 1148 | checkURL("ftps://host:991/" , {"ftps" , "" , "" , "host" , 991, "/" , "" , "" , "ftps://host:991/" }); |
| 1149 | checkURL("ftps://host:990" , {"ftps" , "" , "" , "host" , 990, "" , "" , "" , "ftps://host:990" }); |
| 1150 | checkURL("ftps://host:991" , {"ftps" , "" , "" , "host" , 991, "" , "" , "" , "ftps://host:991" }); |
| 1151 | |
| 1152 | checkURL("uNkNoWn://host:80/" , {"unknown" , "" , "" , "host" , 80, "/" , "" , "" , "unknown://host:80/" }); |
| 1153 | checkURL("unknown://host:80/" , {"unknown" , "" , "" , "host" , 80, "/" , "" , "" , "unknown://host:80/" }); |
| 1154 | checkURL("unknown://host:81/" , {"unknown" , "" , "" , "host" , 81, "/" , "" , "" , "unknown://host:81/" }); |
| 1155 | checkURL("unknown://host:80" , {"unknown" , "" , "" , "host" , 80, "" , "" , "" , "unknown://host:80" }); |
| 1156 | checkURL("unknown://host:81" , {"unknown" , "" , "" , "host" , 81, "" , "" , "" , "unknown://host:81" }); |
| 1157 | |
| 1158 | checkURL("file://host:0" , {"file" , "" , "" , "host" , 0, "/" , "" , "" , "file://host:0/" }); |
| 1159 | checkURL("file://host:80" , {"file" , "" , "" , "host" , 80, "/" , "" , "" , "file://host:80/" }); |
| 1160 | checkURL("file://host:80/path" , {"file" , "" , "" , "host" , 80, "/path" , "" , "" , "file://host:80/path" }); |
| 1161 | checkURLDifferences("file://:80/path" , |
| 1162 | {"" , "" , "" , "" , 0, "" , "" , "" , "file://:80/path" }, |
| 1163 | {"file" , "" , "" , "" , 80, "/path" , "" , "" , "file://:80/path" }); |
| 1164 | checkURLDifferences("file://:0/path" , |
| 1165 | {"" , "" , "" , "" , 0, "" , "" , "" , "file://:0/path" }, |
| 1166 | {"file" , "" , "" , "" , 0, "/path" , "" , "" , "file://:0/path" }); |
| 1167 | |
| 1168 | checkURL("http://example.com:0000000000000077" , {"http" , "" , "" , "example.com" , 77, "/" , "" , "" , "http://example.com:77/" }); |
| 1169 | checkURL("http://example.com:0000000000000080" , {"http" , "" , "" , "example.com" , 0, "/" , "" , "" , "http://example.com/" }); |
| 1170 | } |
| 1171 | |
| 1172 | TEST_F(WTF_URLParser, ParserFailures) |
| 1173 | { |
| 1174 | shouldFail(" " ); |
| 1175 | shouldFail(" \a " ); |
| 1176 | shouldFail("" ); |
| 1177 | shouldFail(String()); |
| 1178 | shouldFail("" , "about:blank" ); |
| 1179 | shouldFail(String(), "about:blank" ); |
| 1180 | shouldFail("http://127.0.0.1:abc" ); |
| 1181 | shouldFail("http://host:abc" ); |
| 1182 | shouldFail("http://:abc" ); |
| 1183 | shouldFail("http://a:@" , "about:blank" ); |
| 1184 | shouldFail("http://:b@" , "about:blank" ); |
| 1185 | shouldFail("http://:@" , "about:blank" ); |
| 1186 | shouldFail("http://a:@" ); |
| 1187 | shouldFail("http://:b@" ); |
| 1188 | shouldFail("http://@" ); |
| 1189 | shouldFail("http://[0:f::f:f:0:0]:abc" ); |
| 1190 | shouldFail("../i" , "sc:sd" ); |
| 1191 | shouldFail("../i" , "sc:sd/sd" ); |
| 1192 | shouldFail("/i" , "sc:sd" ); |
| 1193 | shouldFail("/i" , "sc:sd/sd" ); |
| 1194 | shouldFail("?i" , "sc:sd" ); |
| 1195 | shouldFail("?i" , "sc:sd/sd" ); |
| 1196 | shouldFail("http://example example.com" , "http://other.com/" ); |
| 1197 | shouldFail("http://[www.example.com]/" , "about:blank" ); |
| 1198 | shouldFail("http://192.168.0.1 hello" , "http://other.com/" ); |
| 1199 | shouldFail("http://[example.com]" , "http://other.com/" ); |
| 1200 | shouldFail("i" , "sc:sd" ); |
| 1201 | shouldFail("i" , "sc:sd/sd" ); |
| 1202 | shouldFail("i" ); |
| 1203 | shouldFail("asdf" ); |
| 1204 | shouldFail("~" ); |
| 1205 | shouldFail("%" ); |
| 1206 | shouldFail("//%" ); |
| 1207 | shouldFail("~" , "about:blank" ); |
| 1208 | shouldFail("~~~" ); |
| 1209 | shouldFail("://:0/" ); |
| 1210 | shouldFail("://:0/" , "" ); |
| 1211 | shouldFail("://:0/" , "about:blank" ); |
| 1212 | shouldFail("about~" ); |
| 1213 | shouldFail("//C:asdf/foo/bar" , "file:///tmp/mock/path" ); |
| 1214 | shouldFail("http://[1234::ab#]" ); |
| 1215 | shouldFail("http://[1234::ab/]" ); |
| 1216 | shouldFail("http://[1234::ab?]" ); |
| 1217 | shouldFail("http://[1234::ab@]" ); |
| 1218 | shouldFail("http://[1234::ab~]" ); |
| 1219 | shouldFail("http://[2001::1" ); |
| 1220 | shouldFail("http://4:b\xE1" ); |
| 1221 | shouldFail("http://[1:2:3:4:5:6:7:8~]/" ); |
| 1222 | shouldFail("http://[a:b:c:d:e:f:g:127.0.0.1]" ); |
| 1223 | shouldFail("http://[a:b:c:d:e:f:g:h:127.0.0.1]" ); |
| 1224 | shouldFail("http://[a:b:c:d:e:f:127.0.0.0x11]" ); // Chrome treats this as hex, Firefox and the spec fail |
| 1225 | shouldFail("http://[a:b:c:d:e:f:127.0.-0.1]" ); |
| 1226 | shouldFail("asdf://space In\aHost" ); |
| 1227 | shouldFail("asdf://[0:0:0:0:a:b:c:d" ); |
| 1228 | } |
| 1229 | |
| 1230 | // These are in the spec but not in the web platform tests. |
| 1231 | TEST_F(WTF_URLParser, AdditionalTests) |
| 1232 | { |
| 1233 | checkURL("about:\a\aabc" , {"about" , "" , "" , "" , 0, "%07%07abc" , "" , "" , "about:%07%07abc" }); |
| 1234 | checkURL("notspecial:\t\t\n\t" , {"notspecial" , "" , "" , "" , 0, "" , "" , "" , "notspecial:" }); |
| 1235 | checkURL("notspecial\t\t\n\t:\t\t\n\t/\t\t\n\t/\t\t\n\thost" , {"notspecial" , "" , "" , "host" , 0, "" , "" , "" , "notspecial://host" }); |
| 1236 | checkRelativeURL("http:" , "http://example.org/foo/bar?query#fragment" , {"http" , "" , "" , "example.org" , 0, "/foo/bar" , "query" , "" , "http://example.org/foo/bar?query" }); |
| 1237 | checkRelativeURLDifferences("ws:" , "http://example.org/foo/bar" , |
| 1238 | {"ws" , "" , "" , "" , 0, "" , "" , "" , "ws:" }, |
| 1239 | {"ws" , "" , "" , "" , 0, "s:" , "" , "" , "ws:s:" }); |
| 1240 | checkRelativeURL("notspecial:" , "http://example.org/foo/bar" , {"notspecial" , "" , "" , "" , 0, "" , "" , "" , "notspecial:" }); |
| 1241 | |
| 1242 | const wchar_t surrogateBegin = 0xD800; |
| 1243 | const wchar_t validSurrogateEnd = 0xDD55; |
| 1244 | const wchar_t invalidSurrogateEnd = 'A'; |
| 1245 | const wchar_t replacementCharacter = 0xFFFD; |
| 1246 | checkURL(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, validSurrogateEnd, '\0'}), |
| 1247 | {"http" , "" , "" , "w" , 0, "/%F0%90%85%95" , "" , "" , "http://w/%F0%90%85%95" }, testTabsValueForSurrogatePairs); |
| 1248 | shouldFail(utf16String<10>({'h', 't', 't', 'p', ':', '/', surrogateBegin, invalidSurrogateEnd, '/', '\0'})); |
| 1249 | shouldFail(utf16String<9>({'h', 't', 't', 'p', ':', '/', replacementCharacter, '/', '\0'})); |
| 1250 | |
| 1251 | // URLParser matches Chrome and Firefox but not URL::parse. |
| 1252 | checkURLDifferences(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, invalidSurrogateEnd}), |
| 1253 | {"http" , "" , "" , "w" , 0, "/%EF%BF%BDA" , "" , "" , "http://w/%EF%BF%BDA" }, |
| 1254 | {"http" , "" , "" , "w" , 0, "/%ED%A0%80A" , "" , "" , "http://w/%ED%A0%80A" }); |
| 1255 | checkURLDifferences(utf16String<13>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', '?', surrogateBegin, invalidSurrogateEnd, '\0'}), |
| 1256 | {"http" , "" , "" , "w" , 0, "/" , "%EF%BF%BDA" , "" , "http://w/?%EF%BF%BDA" }, |
| 1257 | {"http" , "" , "" , "w" , 0, "/" , "%ED%A0%80A" , "" , "http://w/?%ED%A0%80A" }); |
| 1258 | checkURLDifferences(utf16String<11>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', surrogateBegin, '\0'}), |
| 1259 | {"http" , "" , "" , "w" , 0, "/%EF%BF%BD" , "" , "" , "http://w/%EF%BF%BD" }, |
| 1260 | {"http" , "" , "" , "w" , 0, "/%ED%A0%80" , "" , "" , "http://w/%ED%A0%80" }); |
| 1261 | checkURLDifferences(utf16String<12>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', '?', surrogateBegin, '\0'}), |
| 1262 | {"http" , "" , "" , "w" , 0, "/" , "%EF%BF%BD" , "" , "http://w/?%EF%BF%BD" }, |
| 1263 | {"http" , "" , "" , "w" , 0, "/" , "%ED%A0%80" , "" , "http://w/?%ED%A0%80" }); |
| 1264 | checkURLDifferences(utf16String<13>({'h', 't', 't', 'p', ':', '/', '/', 'w', '/', '?', surrogateBegin, ' ', '\0'}), |
| 1265 | {"http" , "" , "" , "w" , 0, "/" , "%EF%BF%BD" , "" , "http://w/?%EF%BF%BD" }, |
| 1266 | {"http" , "" , "" , "w" , 0, "/" , "%ED%A0%80" , "" , "http://w/?%ED%A0%80" }); |
| 1267 | |
| 1268 | // FIXME: Write more invalid surrogate pair tests based on feedback from https://bugs.webkit.org/show_bug.cgi?id=162105 |
| 1269 | } |
| 1270 | |
| 1271 | } // namespace TestWebKitAPI |
| 1272 | |