Changeset 206035 in webkit
- Timestamp:
- Sep 16, 2016 11:57:07 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206034 r206035 1 2016-09-16 Alex Christensen <achristensen@webkit.org> 2 3 Fix more edge cases in URLParser 4 https://bugs.webkit.org/show_bug.cgi?id=162051 5 6 Reviewed by Tim Horton. 7 8 Added new API tests. 9 10 * platform/URLParser.cpp: 11 (WebCore::URLParser::parse): 12 Some edge case handling was wrong. Also, some of the terminal states are not possible 13 to reach because we transition to those states without incrementing the iterator. 14 1 15 2016-09-16 Alex Christensen <achristensen@webkit.org> 2 16 -
trunk/Source/WebCore/platform/URLParser.cpp
r205990 r206035 920 920 if (isSpecialScheme(urlScheme)) { 921 921 m_urlIsSpecial = true; 922 // FIXME: This is unnecessarily allocating a String. 923 // This should be easy to optimize once https://bugs.webkit.org/show_bug.cgi?id=162035 lands. 922 924 if (base.protocol() == urlScheme) 923 925 state = State::SpecialRelativeOrAuthority; … … 1057 1059 while (!c.atEnd() && isTabOrNewline(*c)) 1058 1060 ++c; 1059 if (c.atEnd()) 1060 return failure(input, length); 1061 if (*c == '/' || *c == '\\') 1061 if (!c.atEnd() && (*c == '/' || *c == '\\')) 1062 1062 ++c; 1063 1063 } … … 1348 1348 case State::Scheme: 1349 1349 LOG_FINAL_STATE("Scheme"); 1350 break;1350 return failure(input, length); 1351 1351 case State::NoScheme: 1352 1352 LOG_FINAL_STATE("NoScheme"); 1353 break;1353 RELEASE_ASSERT_NOT_REACHED(); 1354 1354 case State::SpecialRelativeOrAuthority: 1355 1355 LOG_FINAL_STATE("SpecialRelativeOrAuthority"); … … 1359 1359 case State::PathOrAuthority: 1360 1360 LOG_FINAL_STATE("PathOrAuthority"); 1361 m_url.m_pathEnd = m_url.m_pathAfterLastSlash; 1362 m_url.m_queryEnd = m_url.m_pathAfterLastSlash; 1363 m_url.m_fragmentEnd = m_url.m_pathAfterLastSlash; 1361 1364 break; 1362 1365 case State::Relative: … … 1388 1391 LOG_FINAL_STATE("SpecialAuthorityIgnoreSlashes"); 1389 1392 return failure(input, length); 1393 break; 1390 1394 case State::AuthorityOrHost: 1391 1395 LOG_FINAL_STATE("AuthorityOrHost"); … … 1466 1470 case State::PathStart: 1467 1471 LOG_FINAL_STATE("PathStart"); 1468 break;1472 RELEASE_ASSERT_NOT_REACHED(); 1469 1473 case State::Path: 1470 1474 LOG_FINAL_STATE("Path"); -
trunk/Tools/ChangeLog
r206033 r206035 1 2016-09-16 Alex Christensen <achristensen@webkit.org> 2 3 Fix more edge cases in URLParser 4 https://bugs.webkit.org/show_bug.cgi?id=162051 5 6 Reviewed by Tim Horton. 7 8 * TestWebKitAPI/Tests/WebCore/URLParser.cpp: 9 (TestWebKitAPI::TEST_F): 10 1 11 2016-09-16 Wenson Hsieh <wenson_hsieh@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp
r205988 r206035 204 204 checkURL("sc://pa/", {"sc", "", "", "pa", 0, "/", "", "", "sc://pa/"}); 205 205 checkURL("http://host \a ", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); 206 checkURL("notspecial:/", {"notspecial", "", "", "", 0, "/", "", "", "notspecial:/"}); 207 checkURL("notspecial:/a", {"notspecial", "", "", "", 0, "/a", "", "", "notspecial:/a"}); 208 checkURL("notspecial:", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); 209 checkURL("http:/a", {"http", "", "", "a", 0, "/", "", "", "http://a/"}); 206 210 // FIXME: Fix and add a test with an invalid surrogate pair at the end with a space as the second code unit. 207 211 … … 280 284 checkRelativeURL(" foo.com ", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/foo.com", "", "", "http://example.org/foo/foo.com"}); 281 285 checkRelativeURL(" \a baz", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/baz", "", "", "http://example.org/foo/baz"}); 286 checkRelativeURL("~", "http://example.org", {"http", "", "", "example.org", 0, "/~", "", "", "http://example.org/~"}); 287 checkRelativeURL("notspecial:/", "about:blank", {"notspecial", "", "", "", 0, "/", "", "", "notspecial:/"}); 288 checkRelativeURL("notspecial:", "about:blank", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); 289 checkRelativeURL("notspecial:/", "http://host", {"notspecial", "", "", "", 0, "/", "", "", "notspecial:/"}); 290 checkRelativeURL("notspecial:", "http://host", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); 291 checkRelativeURL("http:", "http://host", {"http", "", "", "host", 0, "/", "", "", "http://host/"}); 282 292 283 293 // The checking of slashes in SpecialAuthoritySlashes needed to get this to pass contradicts what is in the spec, … … 447 457 {"", "", "", "", 0, "", "", "", "file://notuser:notpassword@test/"}, 448 458 {"file", "notuser", "notpassword", "test", 0, "/", "", "", "file://notuser:notpassword@test/"}); 459 checkRelativeURLDifferences("http:/", "about:blank", 460 {"", "", "", "", 0, "", "", "", "http:/"}, 461 {"http", "", "", "", 0, "/", "", "", "http:/"}); 462 checkRelativeURLDifferences("http:", "about:blank", 463 {"http", "", "", "", 0, "", "", "", "http:"}, 464 {"http", "", "", "", 0, "/", "", "", "http:/"}); 465 checkRelativeURLDifferences("http:/", "http://host", 466 {"", "", "", "", 0, "", "", "", "http:/"}, 467 {"http", "", "", "", 0, "/", "", "", "http:/"}); 468 checkURLDifferences("http:/", 469 {"", "", "", "", 0, "", "", "", "http:/"}, 470 {"http", "", "", "", 0, "/", "", "", "http:/"}); 471 checkURLDifferences("http:", 472 {"http", "", "", "", 0, "", "", "", "http:"}, 473 {"http", "", "", "", 0, "/", "", "", "http:/"}); 449 474 450 475 // This behavior matches Chrome and Firefox, but not WebKit using URL::parse. … … 573 598 { 574 599 shouldFail(" "); 600 shouldFail(" \a "); 575 601 shouldFail(""); 576 602 shouldFail("http://127.0.0.1:abc"); … … 593 619 shouldFail("http://192.168.0.1 hello", "http://other.com/"); 594 620 shouldFail("http://[example.com]", "http://other.com/"); 621 shouldFail("i", "sc:sd"); 622 shouldFail("i", "sc:sd/sd"); 623 shouldFail("i"); 624 shouldFail("asdf"); 625 shouldFail("~"); 626 shouldFail("~", "about:blank"); 627 shouldFail("~~~"); 595 628 } 596 629
Note: See TracChangeset
for help on using the changeset viewer.