Modified: trunk/Source/WebCore/platform/URLParser.cpp (205667 => 205668)
--- trunk/Source/WebCore/platform/URLParser.cpp 2016-09-08 22:15:07 UTC (rev 205667)
+++ trunk/Source/WebCore/platform/URLParser.cpp 2016-09-08 22:16:49 UTC (rev 205668)
@@ -139,7 +139,7 @@
return defaultPorts.get().get(scheme) == port;
}
-static bool isSpecialScheme(const String& scheme)
+static bool isSpecialScheme(StringView scheme)
{
return scheme == "ftp"
|| scheme == "file"
@@ -150,6 +150,13 @@
|| scheme == "wss";
}
+static StringView bufferView(const StringBuilder& builder)
+{
+ if (builder.is8Bit())
+ return StringView(builder.characters8(), builder.length());
+ return StringView(builder.characters16(), builder.length());
+}
+
enum class URLParser::URLPart {
SchemeEnd,
UserStart,
@@ -394,6 +401,7 @@
#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)) {
@@ -417,9 +425,10 @@
m_buffer.append(toASCIILower(*c));
else if (*c == ':') {
m_url.m_schemeEnd = m_buffer.length();
- String urlScheme = m_buffer.toString(); // FIXME: Find a way to do this without shrinking the m_buffer.
+ StringView urlScheme = bufferView(m_buffer);
m_url.m_protocolIsInHTTPFamily = urlScheme == "http" || urlScheme == "https";
if (urlScheme == "file") {
+ urlIsSpecial = true;
state = State::File;
m_buffer.append(':');
++c;
@@ -426,6 +435,7 @@
break;
}
if (isSpecialScheme(urlScheme)) {
+ urlIsSpecial = true;
if (base.protocol() == urlScheme)
state = State::SpecialRelativeOrAuthority;
else
@@ -746,7 +756,7 @@
break;
case State::Path:
LOG_STATE("Path");
- if (*c == '/') {
+ if (*c == '/' || (urlIsSpecial && *c == '\\')) {
m_buffer.append('/');
m_url.m_pathAfterLastSlash = m_buffer.length();
++c;
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (205667 => 205668)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-09-08 22:15:07 UTC (rev 205667)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-09-08 22:16:49 UTC (rev 205668)
@@ -237,6 +237,8 @@
checkRelativeURL("/", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/", "", "", "http://example.org/"});
checkRelativeURL("http://@host", "about:blank", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
checkRelativeURL("http://:@host", "about:blank", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
+ checkRelativeURL("http://foo.com/\\@", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "//@", "", "", "http://foo.com//@"});
+ checkRelativeURL("\\@", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/@", "", "", "http://example.org/@"});
}
static void checkURLDifferences(const String& urlString, const ExpectedParts& partsNew, const ExpectedParts& partsOld)