summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2012-04-12 07:44:24 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-04-12 07:44:24 -0700
commit2d59667e270387d6bf950a6cf680ab3fe0912808 (patch)
treeffbd418bdade008597f9876d54790132013ed1ed /Source
parent5d30564f8e741f67bddb7075478dc1954b7862f9 (diff)
parentdb951b2c4c8fce1304a13d97dec4ae14be629380 (diff)
downloadexternal_webkit-2d59667e270387d6bf950a6cf680ab3fe0912808.zip
external_webkit-2d59667e270387d6bf950a6cf680ab3fe0912808.tar.gz
external_webkit-2d59667e270387d6bf950a6cf680ab3fe0912808.tar.bz2
Merge "Cherry-pick WebKit change r84762 to fix URL canonicalization"
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/KURL.cpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/Source/WebCore/platform/KURL.cpp b/Source/WebCore/platform/KURL.cpp
index 88ad3d9..fd24e3d 100644
--- a/Source/WebCore/platform/KURL.cpp
+++ b/Source/WebCore/platform/KURL.cpp
@@ -1137,6 +1137,23 @@ static inline bool hostPortIsEmptyButCredentialsArePresent(int hostStart, int po
return userEndChar == '@' && hostStart == portEnd;
}
+static bool isNonFileHierarchicalScheme(const char* scheme, size_t schemeLength)
+{
+ switch (schemeLength) {
+ case 2:
+ return equal("ws", 2, scheme, schemeLength);
+ case 3:
+ return equal("ftp", 3, scheme, schemeLength) || equal("wss", 3, scheme, schemeLength);
+ case 4:
+ return equal("http", 4, scheme, schemeLength);
+ case 5:
+ return equal("https", 5, scheme, schemeLength);
+ case 6:
+ return equal("gopher", 6, scheme, schemeLength);
+ }
+ return false;
+}
+
void KURL::parse(const char* url, const String* originalString)
{
if (!url || url[0] == '\0') {
@@ -1173,6 +1190,7 @@ void KURL::parse(const char* url, const String* originalString)
int portEnd;
bool hierarchical = url[schemeEnd + 1] == '/';
+ bool hasSecondSlash = hierarchical && url[schemeEnd + 2] == '/';
bool isFile = schemeEnd == 4
&& matchLetter(url[0], 'f')
@@ -1186,12 +1204,15 @@ void KURL::parse(const char* url, const String* originalString)
&& matchLetter(url[3], 'p')
&& (url[4] == ':' || (matchLetter(url[4], 's') && url[5] == ':'));
- if (hierarchical && url[schemeEnd + 2] == '/') {
+ if ((hierarchical && hasSecondSlash) || isNonFileHierarchicalScheme(url, schemeEnd)) {
// The part after the scheme is either a net_path or an abs_path whose first path segment is empty.
// Attempt to find an authority.
-
// FIXME: Authority characters may be scanned twice, and it would be nice to be faster.
- userStart += 2;
+
+ if (hierarchical)
+ userStart++;
+ if (hasSecondSlash)
+ userStart++;
userEnd = userStart;
int colonPos = 0;
@@ -1394,8 +1415,8 @@ void KURL::parse(const char* url, const String* originalString)
m_userStart = m_userEnd = m_passwordEnd = m_hostEnd = m_portEnd = p - buffer.data();
// For canonicalization, ensure we have a '/' for no path.
- // Do this only for hierarchical URL with protocol http or https.
- if (m_protocolInHTTPFamily && hierarchical && pathEnd == pathStart)
+ // Do this only for URL with protocol http or https.
+ if (m_protocolInHTTPFamily && pathEnd == pathStart)
*p++ = '/';
// add path, escaping bad characters