URLParser should ignore extra slashes after scheme:// and handle a missing slash...
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Sep 2016 21:14:44 +0000 (21:14 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Sep 2016 21:14:44 +0000 (21:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162690

Reviewed by Geoffrey Garen.

Source/WebCore:

Covered by new API tests.

* platform/URLParser.cpp:
(WebCore::URLParser::parse):

Tools:

* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206548 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/URLParser.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp

index d065e01..9bc7290 100644 (file)
@@ -1,5 +1,17 @@
 2016-09-28  Alex Christensen  <achristensen@webkit.org>
 
+        URLParser should ignore extra slashes after scheme:// and handle a missing slash after the port
+        https://bugs.webkit.org/show_bug.cgi?id=162690
+
+        Reviewed by Geoffrey Garen.
+
+        Covered by new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+
+2016-09-28  Alex Christensen  <achristensen@webkit.org>
+
         URLParser should correctly canonicalize uppercase IPv6 addresses
         https://bugs.webkit.org/show_bug.cgi?id=162680
 
index 5448007..5a00d7d 100644 (file)
@@ -1290,12 +1290,13 @@ void URLParser::parse(const CharacterType* input, const unsigned length, const U
         case State::SpecialAuthorityIgnoreSlashes:
             LOG_STATE("SpecialAuthorityIgnoreSlashes");
             if (*c == '/' || *c == '\\') {
-                appendToASCIIBuffer('/');
+                syntaxViolation(c);
                 ++c;
+            } else {
+                m_url.m_userStart = currentPosition(c);
+                state = State::AuthorityOrHost;
+                authorityOrHostBegin = c;
             }
-            m_url.m_userStart = currentPosition(c);
-            state = State::AuthorityOrHost;
-            authorityOrHostBegin = c;
             break;
         case State::AuthorityOrHost:
             do {
@@ -1347,6 +1348,11 @@ void URLParser::parse(const CharacterType* input, const unsigned length, const U
                     failure();
                     return;
                 }
+                if (*c == '?' || *c == '#') {
+                    syntaxViolation(c);
+                    appendToASCIIBuffer('/');
+                    m_url.m_pathAfterLastSlash = currentPosition(c);
+                }
                 state = State::Path;
                 break;
             }
index 7d54108..fa96992 100644 (file)
@@ -1,5 +1,15 @@
 2016-09-28  Alex Christensen  <achristensen@webkit.org>
 
+        URLParser should ignore extra slashes after scheme:// and handle a missing slash after the port
+        https://bugs.webkit.org/show_bug.cgi?id=162690
+
+        Reviewed by Geoffrey Garen.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2016-09-28  Alex Christensen  <achristensen@webkit.org>
+
         URLParser should correctly canonicalize uppercase IPv6 addresses
         https://bugs.webkit.org/show_bug.cgi?id=162680
 
index 5ea9b9d..434d428 100644 (file)
@@ -251,6 +251,11 @@ TEST_F(URLParserTest, Basic)
     checkURL("https://@test@test@example:800\\path@end", {"", "", "", "", 0, "", "", "", "https://@test@test@example:800\\path@end"});
     checkURL("http://www.example.com/#a\nb\rc\td", {"http", "", "", "www.example.com", 0, "/", "", "abcd", "http://www.example.com/#abcd"});
     checkURL("http://[A:b:c:DE:fF:0:1:aC]/", {"http", "", "", "[a:b:c:de:ff:0:1:ac]", 0, "/", "", "", "http://[a:b:c:de:ff:0:1:ac]/"});
+    checkURL("http:////////user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"});
+    checkURL("http:////////user:@webkit.org:99#foo", {"http", "user", "", "webkit.org", 99, "/", "", "foo", "http://user@webkit.org:99/#foo"});
+    checkURL("http:////\t////user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"});
+    checkURL("http://\t//\\///user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"});
+    checkURL("http:/\\user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"});
 
     // This disagrees with the web platform test for http://:@www.example.com but agrees with Chrome and URL::parse,
     // and Firefox fails the web platform test differently. Maybe the web platform test ought to be changed.