Modified: trunk/Source/WebCore/platform/URLParser.cpp (205767 => 205768)
--- trunk/Source/WebCore/platform/URLParser.cpp 2016-09-09 21:20:02 UTC (rev 205767)
+++ trunk/Source/WebCore/platform/URLParser.cpp 2016-09-09 21:29:47 UTC (rev 205768)
@@ -150,12 +150,12 @@
|| scheme == "wss";
}
-static StringView bufferView(const StringBuilder& builder, unsigned length)
+static StringView bufferView(const StringBuilder& builder, unsigned start, unsigned length)
{
ASSERT(builder.length() >= length);
if (builder.is8Bit())
- return StringView(builder.characters8(), length);
- return StringView(builder.characters16(), length);
+ return StringView(builder.characters8() + start, length);
+ return StringView(builder.characters16() + start, length);
}
enum class URLParser::URLPart {
@@ -236,7 +236,7 @@
m_url.m_protocolIsInHTTPFamily = base.m_protocolIsInHTTPFamily;
m_url.m_schemeEnd = base.m_schemeEnd;
}
- m_urlIsSpecial = isSpecialScheme(bufferView(m_buffer, m_url.m_schemeEnd));
+ m_urlIsSpecial = isSpecialScheme(bufferView(m_buffer, 0, m_url.m_schemeEnd));
}
static const char* dotASCIICode = "2e";
@@ -444,7 +444,7 @@
m_buffer.append(toASCIILower(*c));
else if (*c == ':') {
m_url.m_schemeEnd = m_buffer.length();
- StringView urlScheme = bufferView(m_buffer, m_url.m_schemeEnd);
+ StringView urlScheme = bufferView(m_buffer, 0, m_url.m_schemeEnd);
m_url.m_protocolIsInHTTPFamily = urlScheme == "http" || urlScheme == "https";
if (urlScheme == "file") {
m_urlIsSpecial = true;
@@ -761,8 +761,7 @@
if (!parseHost(authorityOrHostBegin, c))
return failure(input);
- // FIXME: Don't allocate a new string for this comparison.
- if (m_buffer.toString().substring(m_url.m_passwordEnd) == "localhost") {
+ if (bufferView(m_buffer, m_url.m_passwordEnd, m_buffer.length() - m_url.m_passwordEnd) == "localhost") {
m_buffer.resize(m_url.m_passwordEnd);
m_url.m_hostEnd = m_buffer.length();
m_url.m_portEnd = m_url.m_hostEnd;
@@ -954,24 +953,19 @@
break;
}
- m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
- m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
- m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
- m_url.m_fragmentEnd = m_url.m_pathAfterLastSlash;
if (!parseHost(authorityOrHostBegin, c))
return failure(input);
- // FIXME: Don't allocate a new string for this comparison.
- if (m_buffer.toString().substring(m_url.m_passwordEnd) == "localhost") {
+ if (bufferView(m_buffer, m_url.m_passwordEnd, m_buffer.length() - m_url.m_passwordEnd) == "localhost") {
m_buffer.resize(m_url.m_passwordEnd);
m_url.m_hostEnd = m_buffer.length();
m_url.m_portEnd = m_url.m_hostEnd;
- m_buffer.append('/');
- m_url.m_pathAfterLastSlash = m_url.m_hostEnd + 1;
- m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
- m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
- m_url.m_fragmentEnd = m_url.m_pathAfterLastSlash;
}
+ m_buffer.append('/');
+ m_url.m_pathAfterLastSlash = m_url.m_hostEnd + 1;
+ m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
+ m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
+ m_url.m_fragmentEnd = m_url.m_pathAfterLastSlash;
break;
case State::PathStart:
LOG_FINAL_STATE("PathStart");
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (205767 => 205768)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-09-09 21:20:02 UTC (rev 205767)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-09-09 21:29:47 UTC (rev 205768)
@@ -157,6 +157,8 @@
checkURL("file:////", {"file", "", "", "", 0, "//", "", "", "file:////"}); // This matches Firefox and URL::parse which I believe are correct, but not Chrome.
checkURL("file:/path", {"file", "", "", "", 0, "/path", "", "", "file:///path"});
checkURL("file://host/path", {"file", "", "", "host", 0, "/path", "", "", "file://host/path"});
+ checkURL("file://host", {"file", "", "", "host", 0, "/", "", "", "file://host/"});
+ checkURL("file://host/", {"file", "", "", "host", 0, "/", "", "", "file://host/"});
checkURL("file:///path", {"file", "", "", "", 0, "/path", "", "", "file:///path"});
checkURL("file:////path", {"file", "", "", "", 0, "//path", "", "", "file:////path"});
checkURL("file://localhost/path", {"file", "", "", "", 0, "/path", "", "", "file:///path"});
@@ -423,6 +425,12 @@
checkRelativeURLDifferences("notspecial:\\\\foo.com", "http://example.org/foo/bar",
{"notspecial", "", "", "", 0, "\\\\foo.com", "", "", "notspecial:\\\\foo.com"},
{"notspecial", "", "", "foo.com", 0, "", "", "", "notspecial://foo.com"});
+ checkURLDifferences("file://notuser:notpassword@test",
+ {"", "", "", "", 0, "", "", "", "file://notuser:notpassword@test"},
+ {"file", "notuser", "notpassword", "test", 0, "/", "", "", "file://notuser:notpassword@test/"});
+ checkURLDifferences("file://notuser:notpassword@test/",
+ {"", "", "", "", 0, "", "", "", "file://notuser:notpassword@test/"},
+ {"file", "notuser", "notpassword", "test", 0, "/", "", "", "file://notuser:notpassword@test/"});
// This behavior matches Chrome and Firefox, but not WebKit using URL::parse.
// The behavior of URL::parse is clearly wrong because reparsing file://path would make path the host.