Modified: trunk/Source/WebCore/platform/URLParser.cpp (205683 => 205684)
--- trunk/Source/WebCore/platform/URLParser.cpp 2016-09-09 01:22:05 UTC (rev 205683)
+++ trunk/Source/WebCore/platform/URLParser.cpp 2016-09-09 01:32:18 UTC (rev 205684)
@@ -150,11 +150,12 @@
|| scheme == "wss";
}
-static StringView bufferView(const StringBuilder& builder)
+static StringView bufferView(const StringBuilder& builder, unsigned length)
{
+ ASSERT(builder.length() >= length);
if (builder.is8Bit())
- return StringView(builder.characters8(), builder.length());
- return StringView(builder.characters16(), builder.length());
+ return StringView(builder.characters8(), length);
+ return StringView(builder.characters16(), length);
}
enum class URLParser::URLPart {
@@ -235,6 +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));
}
static const char* dotASCIICode = "2e";
@@ -420,7 +422,6 @@
#define LOG_STATE(x) LOG(URLParser, "State %s, code point %c, buffer length %d", x, *c, m_buffer.length())
#define LOG_FINAL_STATE(x) LOG(URLParser, "Final State: %s", x)
- bool urlIsSpecial = false;
State state = State::SchemeStart;
while (c != end) {
if (isTabOrNewline(*c)) {
@@ -444,10 +445,10 @@
m_buffer.append(toASCIILower(*c));
else if (*c == ':') {
m_url.m_schemeEnd = m_buffer.length();
- StringView urlScheme = bufferView(m_buffer);
+ StringView urlScheme = bufferView(m_buffer, m_url.m_schemeEnd);
m_url.m_protocolIsInHTTPFamily = urlScheme == "http" || urlScheme == "https";
if (urlScheme == "file") {
- urlIsSpecial = true;
+ m_urlIsSpecial = true;
state = State::File;
m_buffer.append(':');
++c;
@@ -454,7 +455,7 @@
break;
}
if (isSpecialScheme(urlScheme)) {
- urlIsSpecial = true;
+ m_urlIsSpecial = true;
if (base.protocol() == urlScheme)
state = State::SpecialRelativeOrAuthority;
else
@@ -775,7 +776,7 @@
break;
case State::Path:
LOG_STATE("Path");
- if (*c == '/' || (urlIsSpecial && *c == '\\')) {
+ if (*c == '/' || (m_urlIsSpecial && *c == '\\')) {
m_buffer.append('/');
m_url.m_pathAfterLastSlash = m_buffer.length();
++c;
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (205683 => 205684)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-09-09 01:22:05 UTC (rev 205683)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-09-09 01:32:18 UTC (rev 205684)
@@ -256,6 +256,7 @@
checkRelativeURL("/path3", "http://u...@example.org/path1/path2", {"http", "user", "", "example.org", 0, "/path3", "", "", "http://u...@example.org/path3"});
checkRelativeURL("", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"});
checkRelativeURL(" \a \t\n", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"});
+ checkRelativeURL(":foo.com\\", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/:foo.com/", "", "", "http://example.org/foo/:foo.com/"});
}
static void checkURLDifferences(const String& urlString, const ExpectedParts& partsNew, const ExpectedParts& partsOld)
@@ -398,6 +399,9 @@
checkURLDifferences("http://[0:f::f:f:0:0]:65536",
{"", "", "", "", 0, "", "", "", "http://[0:f::f:f:0:0]:65536"},
{"http", "", "", "[0:f::f:f:0:0]", 65535, "/", "", "", "http://[0:f::f:f:0:0]:65536/"});
+ checkRelativeURLDifferences(":foo.com\\", "notspecial://example.org/foo/bar",
+ {"notspecial", "", "", "example.org", 0, "/foo/:foo.com\\", "", "", "notspecial://example.org/foo/:foo.com\\"},
+ {"notspecial", "", "", "example.org", 0, "/foo/:foo.com/", "", "", "notspecial://example.org/foo/:foo.com/"});
// 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.