Changeset 205650 in webkit
- Timestamp:
- Sep 8, 2016 10:23:30 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r205649 r205650 1 2016-09-08 Alex Christensen <achristensen@webkit.org> 2 3 Re-land r205580 after r205649 fixed the test failures 4 https://bugs.webkit.org/show_bug.cgi?id=161668 5 6 Re-landing changesets: 7 8 "Punycode encode non-ascii hosts in URLParser" 9 https://bugs.webkit.org/show_bug.cgi?id=161655 10 http://trac.webkit.org/changeset/205521 11 12 "Fix query-only and fragment-only relative URLs when using 13 URLParser" 14 https://bugs.webkit.org/show_bug.cgi?id=161657 15 http://trac.webkit.org/changeset/205526 16 17 "URLParser should parse / as a relative URL" 18 https://bugs.webkit.org/show_bug.cgi?id=161667 19 http://trac.webkit.org/changeset/205532 20 1 21 2016-09-08 Alex Christensen <achristensen@webkit.org> 2 22 -
trunk/Source/WebCore/platform/URLParser.cpp
r205649 r205650 29 29 #include "Logging.h" 30 30 #include <array> 31 #include <unicode/uidna.h> 31 32 #include <wtf/HashMap.h> 32 33 #include <wtf/NeverDestroyed.h> … … 451 452 LOG_STATE("SchemeEndCheckForSlashes"); 452 453 if (*c == '/') { 453 m_buffer.append('/'); 454 m_buffer.append("//"); 455 m_url.m_userStart = m_buffer.length(); 454 456 state = State::PathOrAuthority; 455 457 ++c; … … 516 518 case '?': 517 519 copyURLPartsUntil(base, URLPart::PathEnd); 520 m_buffer.append('?'); 518 521 state = State::Query; 519 522 ++c; … … 521 524 case '#': 522 525 copyURLPartsUntil(base, URLPart::QueryEnd); 526 m_buffer.append('#'); 523 527 state = State::Fragment; 524 528 ++c; … … 842 846 case State::RelativeSlash: 843 847 LOG_FINAL_STATE("RelativeSlash"); 848 copyURLPartsUntil(base, URLPart::PortEnd); 849 m_buffer.append('/'); 850 m_url.m_pathAfterLastSlash = base.m_portEnd + 1; 851 m_url.m_pathEnd = m_url.m_pathAfterLastSlash; 852 m_url.m_queryEnd = m_url.m_pathAfterLastSlash; 853 m_url.m_fragmentEnd = m_url.m_pathAfterLastSlash; 844 854 break; 845 855 case State::SpecialAuthoritySlashes: … … 1270 1280 } 1271 1281 1282 static bool containsOnlyASCII(const String& string) 1283 { 1284 if (string.is8Bit()) 1285 return charactersAreAllASCII(string.characters8(), string.length()); 1286 return charactersAreAllASCII(string.characters16(), string.length()); 1287 } 1288 1272 1289 static Optional<String> domainToASCII(const String& domain) 1273 1290 { 1274 // FIXME: Implement correctly 1275 CString utf8 = domain.utf8(); 1276 return String(utf8.data(), utf8.length()); 1291 const unsigned hostnameBufferLength = 2048; 1292 1293 if (containsOnlyASCII(domain)) { 1294 if (domain.is8Bit()) 1295 return domain; 1296 Vector<LChar, hostnameBufferLength> buffer; 1297 size_t length = domain.length(); 1298 buffer.reserveInitialCapacity(length); 1299 for (size_t i = 0; i < length; ++i) 1300 buffer.append(domain[i]); 1301 return String(buffer.data(), length); 1302 } 1303 1304 UChar hostnameBuffer[hostnameBufferLength]; 1305 UErrorCode error = U_ZERO_ERROR; 1306 1307 int32_t numCharactersConverted = uidna_IDNToASCII(StringView(domain).upconvertedCharacters(), domain.length(), hostnameBuffer, hostnameBufferLength, UIDNA_ALLOW_UNASSIGNED, nullptr, &error); 1308 1309 if (error == U_ZERO_ERROR) { 1310 LChar buffer[hostnameBufferLength]; 1311 for (int32_t i = 0; i < numCharactersConverted; ++i) { 1312 ASSERT(isASCII(hostnameBuffer[i])); 1313 buffer[i] = hostnameBuffer[i]; 1314 } 1315 return String(buffer, numCharactersConverted); 1316 } 1317 1318 // FIXME: Check for U_BUFFER_OVERFLOW_ERROR and retry with an allocated buffer. 1319 return Nullopt; 1277 1320 } 1278 1321 -
trunk/Tools/ChangeLog
r205618 r205650 1 2016-09-08 Alex Christensen <achristensen@webkit.org> 2 3 Re-land r205580 after r205649 fixed the test failures 4 https://bugs.webkit.org/show_bug.cgi?id=161668 5 6 Re-landing changesets: 7 8 "Punycode encode non-ascii hosts in URLParser" 9 https://bugs.webkit.org/show_bug.cgi?id=161655 10 http://trac.webkit.org/changeset/205521 11 12 "Fix query-only and fragment-only relative URLs when using 13 URLParser" 14 https://bugs.webkit.org/show_bug.cgi?id=161657 15 http://trac.webkit.org/changeset/205526 16 17 "URLParser should parse / as a relative URL" 18 https://bugs.webkit.org/show_bug.cgi?id=161667 19 http://trac.webkit.org/changeset/205532 20 1 21 2016-09-08 Dean Jackson <dino@apple.com> 2 22 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp
r205584 r205650 83 83 84 84 EXPECT_TRUE(URLParser::allValuesEqual(url, oldURL)); 85 } 86 87 template<size_t length> 88 static String wideString(const wchar_t (&url)[length]) 89 { 90 StringBuilder builder; 91 builder.reserveCapacity(length - 1); 92 for (size_t i = 0; i < length - 1; ++i) 93 builder.append(url[i]); 94 return builder.toString(); 85 95 } 86 96 … … 210 220 checkRelativeURL("http://example\t.\norg", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/", "", "", "http://example.org/"}); 211 221 checkRelativeURL("test", "file:///path1/path2", {"file", "", "", "", 0, "/path1/test", "", "", "file:///path1/test"}); 222 checkRelativeURL(wideString(L"http://www.foo。bar.com"), "http://other.com/", {"http", "", "", "www.foo.bar.com", 0, "/", "", "", "http://www.foo.bar.com/"}); 223 checkRelativeURL(wideString(L"sc://ñ.test/"), "about:blank", {"sc", "", "", "xn--ida.test", 0, "/", "", "", "sc://xn--ida.test/"}); 224 checkRelativeURL("#fragment", "http://host/path", {"http", "", "", "host", 0, "/path", "", "fragment", "http://host/path#fragment"}); 225 checkRelativeURL("?query", "http://host/path", {"http", "", "", "host", 0, "/path", "query", "", "http://host/path?query"}); 226 checkRelativeURL("?query#fragment", "http://host/path", {"http", "", "", "host", 0, "/path", "query", "fragment", "http://host/path?query#fragment"}); 227 checkRelativeURL(wideString(L"?β"), "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "%CE%B2", "", "http://example.org/foo/bar?%CE%B2"}); 228 checkRelativeURL("?", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar?"}); 229 checkRelativeURL("#", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar#"}); 230 checkRelativeURL("?#", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar?#"}); 231 checkRelativeURL("#?", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "?", "http://example.org/foo/bar#?"}); 232 checkRelativeURL("/", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/", "", "", "http://example.org/"}); 212 233 } 213 234 … … 331 352 {"file", "", "", "[0:a::b:c:0:0]", 0, "/path", "", "", "file://[0:a::b:c:0:0]/path"}, 332 353 {"file", "", "", "[0:a:0:0:b:c:0:0]", 0, "/path", "", "", "file://[0:a:0:0:b:c:0:0]/path"}); 354 checkRelativeURLDifferences(wideString(L"#β"), "http://example.org/foo/bar", 355 {"http", "", "", "example.org", 0, "/foo/bar", "", wideString(L"β"), wideString(L"http://example.org/foo/bar#β")}, 356 {"http", "", "", "example.org", 0, "/foo/bar", "", "%CE%B2", "http://example.org/foo/bar#%CE%B2"}); 333 357 334 358 // FIXME: This behavior ought to be specified in the standard. … … 352 376 353 377 // URLParser matches Chrome and the spec, but not URL::parse or Firefox. 378 checkURLDifferences(wideString(L"http://0Xc0.0250.01"), 379 {"http", "", "", "192.168.0.1", 0, "/", "", "", "http://192.168.0.1/"}, 380 {"http", "", "", "0xc0.0250.01", 0, "/", "", "", "http://0xc0.0250.01/"}); 354 381 checkURLDifferences("http://host/path%2e.%2E", 355 382 {"http", "", "", "host", 0, "/path...", "", "", "http://host/path..."},
Note: See TracChangeset
for help on using the changeset viewer.