Skip to content

Commit

Permalink
Merge r205194 - URLParser should handle relative URLs that start with //
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=161364

Reviewed by Darin Adler.

Source/WebCore:

Covered by an API test.

* platform/URLParser.cpp:
(WebCore::URLParser::parse):

Tools:

* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkRelativeURL):
(TestWebKitAPI::TEST_F):

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.14@205589 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
[email protected] committed Sep 8, 2016
1 parent defaa8f commit e5cf0b8
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
2016-08-30 Alex Christensen <[email protected]>

URLParser should handle relative URLs that start with //
https://bugs.webkit.org/show_bug.cgi?id=161364

Reviewed by Darin Adler.

Covered by an API test.

* platform/URLParser.cpp:
(WebCore::URLParser::parse):

2016-08-30 Zalan Bujtas <[email protected]>

ASSERTION FAILED: opportunitiesInRun <= expansionOpportunityCount in WebCore::computeExpansionForJustifiedText
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/platform/URLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ URL URLParser::parse(const String& input, const URL& base, const TextEncoding&)
LOG_STATE("RelativeSlash");
if (*c == '/' || *c == '\\') {
++c;
copyURLPartsUntil(base, URLPart::SchemeEnd);
m_buffer.append("://");
state = State::SpecialAuthorityIgnoreSlashes;
} else {
copyURLPartsUntil(base, URLPart::PortEnd);
Expand Down
11 changes: 11 additions & 0 deletions Tools/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2016-08-30 Alex Christensen <[email protected]>

URLParser should handle relative URLs that start with //
https://bugs.webkit.org/show_bug.cgi?id=161364

Reviewed by Darin Adler.

* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkRelativeURL):
(TestWebKitAPI::TEST_F):

2016-08-29 Aakash Jain <[email protected]>

EWS patch status page should indicate bot corresponding to each status message
Expand Down
38 changes: 38 additions & 0 deletions Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ TEST_F(URLParserTest, ParseRelative)
checkRelativeURL("/index.html", "http://webkit.org/path1/path2/", {"http", "", "", "webkit.org", 0, "/index.html", "", "", "http://webkit.org/index.html"});
checkRelativeURL("http://whatwg.org/index.html", "http://webkit.org/path1/path2/", {"http", "", "", "whatwg.org", 0, "/index.html", "", "", "http://whatwg.org/index.html"});
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"});
checkRelativeURL("//whatwg.org/index.html", "https://www.webkit.org/path", {"https", "", "", "whatwg.org", 0, "/index.html", "", "", "https://whatwg.org/index.html"});
}

static void checkURLDifferences(const String& urlString, const ExpectedParts& partsNew, const ExpectedParts& partsOld)
Expand Down Expand Up @@ -162,6 +163,37 @@ static void checkURLDifferences(const String& urlString, const ExpectedParts& pa
EXPECT_FALSE(URLParser::allValuesEqual(url, oldURL));
}

static void checkRelativeURLDifferences(const String& urlString, const String& baseURLString, const ExpectedParts& partsNew, const ExpectedParts& partsOld)
{
URLParser baseParser;
auto base = baseParser.parse(baseURLString);

URLParser parser;
auto url = parser.parse(urlString, base);
EXPECT_TRUE(eq(partsNew.protocol, url.protocol()));
EXPECT_TRUE(eq(partsNew.user, url.user()));
EXPECT_TRUE(eq(partsNew.password, url.pass()));
EXPECT_TRUE(eq(partsNew.host, url.host()));
EXPECT_EQ(partsNew.port, url.port());
EXPECT_TRUE(eq(partsNew.path, url.path()));
EXPECT_TRUE(eq(partsNew.query, url.query()));
EXPECT_TRUE(eq(partsNew.fragment, url.fragmentIdentifier()));
EXPECT_TRUE(eq(partsNew.string, url.string()));

auto oldURL = URL(URL(URL(), baseURLString), urlString);
EXPECT_TRUE(eq(partsOld.protocol, oldURL.protocol()));
EXPECT_TRUE(eq(partsOld.user, oldURL.user()));
EXPECT_TRUE(eq(partsOld.password, oldURL.pass()));
EXPECT_TRUE(eq(partsOld.host, oldURL.host()));
EXPECT_EQ(partsOld.port, oldURL.port());
EXPECT_TRUE(eq(partsOld.path, oldURL.path()));
EXPECT_TRUE(eq(partsOld.query, oldURL.query()));
EXPECT_TRUE(eq(partsOld.fragment, oldURL.fragmentIdentifier()));
EXPECT_TRUE(eq(partsOld.string, oldURL.string()));

EXPECT_FALSE(URLParser::allValuesEqual(url, oldURL));
}

TEST_F(URLParserTest, ParserDifferences)
{
checkURLDifferences("http://127.0.1",
Expand All @@ -170,6 +202,12 @@ TEST_F(URLParserTest, ParserDifferences)
checkURLDifferences("http://011.11.0X11.0x011",
{"http", "", "", "9.11.17.17", 0, "/", "", "", "http://9.11.17.17/"},
{"http", "", "", "011.11.0x11.0x011", 0, "/", "", "", "http://011.11.0x11.0x011/"});

// FIXME: This behavior ought to be specified in the standard.
// With the existing URL::parse, WebKit returns "https:/", Firefox returns "https:///", and Chrome throws an error.
checkRelativeURLDifferences("//", "https://www.webkit.org/path",
{"https", "", "", "", 0, "", "", "", "https://"},
{"https", "", "", "", 0, "/", "", "", "https:/"});
}

static void shouldFail(const String& urlString)
Expand Down

0 comments on commit e5cf0b8

Please sign in to comment.