Title: [174712] trunk
Revision
174712
Author
m...@apple.com
Date
2014-10-14 16:58:34 -0700 (Tue, 14 Oct 2014)

Log Message

URLs that start with http:/// and https:/// lose two slashes when parsed, causing assertion failure and inconsistent behavior
https://bugs.webkit.org/show_bug.cgi?id=137718

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Added cases to fast/loader/url-parse-1.html.

* platform/URL.cpp:
(WebCore::URL::parse): In hierarchical schemes other than file:, ignore any additional
slashes after the ://, as prescribed by the authority-ignore-slashes state in the current
URL spec.

LayoutTests:

* fast/loader/url-parse-1-expected.txt: Updated results.
* fast/loader/url-parse-1.html: Added a few test cases.
* fast/url/file-http-base-expected.txt: Updated results.
* fast/url/host-expected.txt: Ditto.
* fast/url/invalid-urls-utf8-expected.txt: Ditto.
* fast/url/relative-expected.txt: Ditto.
* fast/url/standard-url-expected.txt: Ditto.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (174711 => 174712)


--- trunk/LayoutTests/ChangeLog	2014-10-14 23:46:45 UTC (rev 174711)
+++ trunk/LayoutTests/ChangeLog	2014-10-14 23:58:34 UTC (rev 174712)
@@ -1,3 +1,18 @@
+2014-10-14  Dan Bernstein  <m...@apple.com>
+
+        URLs that start with http:/// and https:/// lose two slashes when parsed, causing assertion failure and inconsistent behavior
+        https://bugs.webkit.org/show_bug.cgi?id=137718
+
+        Reviewed by Alexey Proskuryakov.
+
+        * fast/loader/url-parse-1-expected.txt: Updated results.
+        * fast/loader/url-parse-1.html: Added a few test cases.
+        * fast/url/file-http-base-expected.txt: Updated results.
+        * fast/url/host-expected.txt: Ditto.
+        * fast/url/invalid-urls-utf8-expected.txt: Ditto.
+        * fast/url/relative-expected.txt: Ditto.
+        * fast/url/standard-url-expected.txt: Ditto.
+
 2014-10-14  Alexey Proskuryakov  <a...@apple.com>
 
         Re-adding fast/hidpi/image-srcset-relative-svg-canvas.html, as it still fails on bots

Modified: trunk/LayoutTests/fast/loader/url-parse-1-expected.txt (174711 => 174712)


--- trunk/LayoutTests/fast/loader/url-parse-1-expected.txt	2014-10-14 23:46:45 UTC (rev 174711)
+++ trunk/LayoutTests/fast/loader/url-parse-1-expected.txt	2014-10-14 23:58:34 UTC (rev 174712)
@@ -24,7 +24,15 @@
 http:/	http:/		/
 http://	http:/		/
 http:///	http:/		/
-http:////	http://		//
+http:////	http:/		/
+http:webkit.org	http://webkit.org/	webkit.org	/
+http:/webkit.org	http://webkit.org/	webkit.org	/
+http://webkit.org	http://webkit.org/	webkit.org	/
+http:///webkit.org	http://webkit.org/	webkit.org	/
+http:////webkit.org	http://webkit.org/	webkit.org	/
+http://///webkit.org	http://webkit.org/	webkit.org	/
+http://////webkit.org	http://webkit.org/	webkit.org	/
+http:////////////////webkit.org	http://webkit.org/	webkit.org	/
 http://localhost	http://localhost/	localhost	/
 http://localhost/	http://localhost/	localhost	/
 http://localhost/test	http://localhost/test	localhost	/test

Modified: trunk/LayoutTests/fast/loader/url-parse-1.html (174711 => 174712)


--- trunk/LayoutTests/fast/loader/url-parse-1.html	2014-10-14 23:46:45 UTC (rev 174711)
+++ trunk/LayoutTests/fast/loader/url-parse-1.html	2014-10-14 23:58:34 UTC (rev 174712)
@@ -67,6 +67,14 @@
             "http://",
             "http:///",
             "http:////",
+            "http:webkit.org",
+            "http:/webkit.org",
+            "http://webkit.org",
+            "http:///webkit.org",
+            "http:////webkit.org",
+            "http://///webkit.org",
+            "http://////webkit.org",
+            "http:////////////////webkit.org",
             "http://localhost",
             "http://localhost/",
             "http://localhost/test",

Modified: trunk/LayoutTests/fast/url/file-http-base-expected.txt (174711 => 174712)


--- trunk/LayoutTests/fast/url/file-http-base-expected.txt	2014-10-14 23:46:45 UTC (rev 174711)
+++ trunk/LayoutTests/fast/url/file-http-base-expected.txt	2014-10-14 23:58:34 UTC (rev 174712)
@@ -27,7 +27,7 @@
 FAIL canonicalize('file:c|//foo\\bar.html') should be file:///c%7C//foo/bar.html. Was file://c|//foo/bar.html.
 FAIL canonicalize('//') should be file:///. Was http:/.
 FAIL canonicalize('///') should be file:///. Was http:/.
-FAIL canonicalize('///test') should be file:///test. Was http:/test.
+FAIL canonicalize('///test') should be file:///test. Was http://test/.
 PASS canonicalize('file://test') is 'file://test/'
 FAIL canonicalize('file://localhost') should be file://localhost/. Was file:///.
 FAIL canonicalize('file://localhost/') should be file://localhost/. Was file:///.

Modified: trunk/LayoutTests/fast/url/host-expected.txt (174711 => 174712)


--- trunk/LayoutTests/fast/url/host-expected.txt	2014-10-14 23:46:45 UTC (rev 174711)
+++ trunk/LayoutTests/fast/url/host-expected.txt	2014-10-14 23:58:34 UTC (rev 174712)
@@ -33,16 +33,16 @@
 FAIL canonicalize('http://www.lookout.net::==80::==443::/') should be http://www.lookout.net::%3D%3D80::%3D%3D443:/. Was http://www.lookout.net::==80::==443::/.
 PASS canonicalize('http://www.lookout.net::80::443/') is 'http://www.lookout.net::80::443/'
 PASS canonicalize('http://\.//') is 'http://.//'
-FAIL canonicalize('http:////:@//') should be http:////. Was http://:@//.
+FAIL canonicalize('http:////:@//') should be http:////. Was http:////:@//.
 PASS canonicalize('http://\google.com/foo/') is 'http://google.com/foo/'
-FAIL canonicalize('http://\\google.com/foo/') should be http://google.com/foo/. Was http:/google.com/foo/.
-PASS canonicalize('http:////asdf@//') is 'http://asdf@//'
+PASS canonicalize('http://\\google.com/foo/') is 'http://google.com/foo/'
+FAIL canonicalize('http:////asdf@//') should be http://asdf@//. Was http:////asdf@//.
 PASS canonicalize('http:////:81/') is 'http://:81/'
 PASS canonicalize('http://:///') is 'http://:///'
 PASS canonicalize('http://c:/') is 'http://c/'
 PASS canonicalize('http://xxxx:/') is 'http://xxxx/'
 PASS canonicalize('http://.:./') is 'http://.:./'
-FAIL canonicalize('http://////@google.com//') should be http://google.com//. Was http:////@google.com//.
+PASS canonicalize('http://////@google.com//') is 'http://google.com//'
 PASS canonicalize('http://@google.com/') is 'http://google.com/'
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/fast/url/invalid-urls-utf8-expected.txt (174711 => 174712)


--- trunk/LayoutTests/fast/url/invalid-urls-utf8-expected.txt	2014-10-14 23:46:45 UTC (rev 174711)
+++ trunk/LayoutTests/fast/url/invalid-urls-utf8-expected.txt	2014-10-14 23:58:34 UTC (rev 174712)
@@ -5,6 +5,10 @@
 
 FAIL src should be http:///. Was http:/.
 FAIL src should be https:///. Was https:/.
+FAIL src should be ftp:///. Was ftp://.
+FAIL src should be gopher:///. Was gopher://.
+FAIL src should be ws:///. Was ws://.
+FAIL src should be wss:///. Was wss://.
 PASS src is expected
 PASS src is expected
 PASS src is expected
@@ -21,10 +25,6 @@
 PASS src is expected
 PASS src is expected
 PASS src is expected
-PASS src is expected
-PASS src is expected
-PASS src is expected
-PASS src is expected
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/url/relative-expected.txt (174711 => 174712)


--- trunk/LayoutTests/fast/url/relative-expected.txt	2014-10-14 23:46:45 UTC (rev 174711)
+++ trunk/LayoutTests/fast/url/relative-expected.txt	2014-10-14 23:58:34 UTC (rev 174712)
@@ -52,7 +52,7 @@
 PASS canonicalize(';/../bar') is 'http://host/bar'
 PASS canonicalize('//another') is 'http://another/'
 PASS canonicalize('//another/path?query#ref') is 'http://another/path?query#ref'
-FAIL canonicalize('///another/path') should be http://another/path. Was http:/another/path.
+PASS canonicalize('///another/path') is 'http://another/path'
 PASS canonicalize('//Another\\path') is 'http://another/path'
 FAIL canonicalize('//') should be http:. Was http:/.
 PASS canonicalize('\\/another/path') is 'http://another/path'

Modified: trunk/LayoutTests/fast/url/standard-url-expected.txt (174711 => 174712)


--- trunk/LayoutTests/fast/url/standard-url-expected.txt	2014-10-14 23:46:45 UTC (rev 174711)
+++ trunk/LayoutTests/fast/url/standard-url-expected.txt	2014-10-14 23:58:34 UTC (rev 174712)
@@ -7,7 +7,7 @@
 FAIL canonicalize('http://www.google.com/foo?bar=baz# »') should be http://www.google.com/foo?bar=baz# ». Was http://www.google.com/foo?bar=baz# %BB.
 PASS canonicalize('http://[www.google.com]/') is 'http://[www.google.com]/'
 PASS canonicalize('http://www.google.com') is 'http://www.google.com/'
-FAIL canonicalize('http:////////user:@google.com:99?foo') should be http://u...@google.com:99/?foo. Was http://////user:@google.com:99?foo.
+PASS canonicalize('http:////////user:@google.com:99?foo') is 'http://u...@google.com:99/?foo'
 FAIL canonicalize('http://192.0x00A80001') should be http://192.168.0.1/. Was http://192.0x00a80001/.
 FAIL canonicalize('http://www/foo%2Ehtml') should be http://www/foo.html. Was http://www/foo%2Ehtml.
 PASS canonicalize('http://user:pass@/') is 'http://user:pass@/'

Modified: trunk/Source/WebCore/ChangeLog (174711 => 174712)


--- trunk/Source/WebCore/ChangeLog	2014-10-14 23:46:45 UTC (rev 174711)
+++ trunk/Source/WebCore/ChangeLog	2014-10-14 23:58:34 UTC (rev 174712)
@@ -1,3 +1,17 @@
+2014-10-14  Dan Bernstein  <m...@apple.com>
+
+        URLs that start with http:/// and https:/// lose two slashes when parsed, causing assertion failure and inconsistent behavior
+        https://bugs.webkit.org/show_bug.cgi?id=137718
+
+        Reviewed by Alexey Proskuryakov.
+
+        Added cases to fast/loader/url-parse-1.html.
+
+        * platform/URL.cpp:
+        (WebCore::URL::parse): In hierarchical schemes other than file:, ignore any additional
+        slashes after the ://, as prescribed by the authority-ignore-slashes state in the current
+        URL spec.
+
 2014-10-14  Brent Fulgham  <bfulg...@apple.com>
 
         [Win] Unreviewed build fix after r174698 and r174709.

Modified: trunk/Source/WebCore/platform/URL.cpp (174711 => 174712)


--- trunk/Source/WebCore/platform/URL.cpp	2014-10-14 23:46:45 UTC (rev 174711)
+++ trunk/Source/WebCore/platform/URL.cpp	2014-10-14 23:58:34 UTC (rev 174712)
@@ -247,7 +247,7 @@
 static inline bool isPathSegmentEndChar(char c) { return characterClassTable[static_cast<unsigned char>(c)] & PathSegmentEndChar; }
 static inline bool isPathSegmentEndChar(UChar c) { return c <= 0xff && (characterClassTable[c] & PathSegmentEndChar); }
 static inline bool isBadChar(unsigned char c) { return characterClassTable[c] & BadChar; }
-    
+
 static inline bool isSchemeCharacterMatchIgnoringCase(char character, char schemeCharacter)
 {
     ASSERT(isSchemeChar(character));
@@ -1140,10 +1140,17 @@
         // Attempt to find an authority.
         // FIXME: Authority characters may be scanned twice, and it would be nice to be faster.
 
-        if (hierarchical)
+        if (hierarchical) {
             userStart++;
-        if (hasSecondSlash)
-            userStart++;
+            if (hasSecondSlash) {
+                userStart++;
+                if (isNonFileHierarchicalScheme(url, schemeEnd)) {
+                    while (url[userStart] == '/')
+                        userStart++;
+                }
+            }
+        }
+
         userEnd = userStart;
 
         int colonPos = 0;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to