URLParser should ignore tabs in authority
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Sep 2016 21:16:22 +0000 (21:16 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Sep 2016 21:16:22 +0000 (21:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162694

Reviewed by Geoffrey Garen.

Source/WebCore:

Covered by new API tests.

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

Tools:

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

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

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

index 9bc7290..8ca91d0 100644 (file)
@@ -1,5 +1,17 @@
 2016-09-28  Alex Christensen  <achristensen@webkit.org>
 
+        URLParser should ignore tabs in authority
+        https://bugs.webkit.org/show_bug.cgi?id=162694
+
+        Reviewed by Geoffrey Garen.
+
+        Covered by new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parseAuthority):
+
+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
 
index 5a00d7d..96cbfba 100644 (file)
@@ -1847,12 +1847,16 @@ void URLParser::parseAuthority(CodePointIterator<CharacterType> iterator)
         m_url.m_passwordEnd = m_url.m_userEnd;
         return;
     }
-    auto authorityOrHostBegin = iterator;
     for (; !iterator.atEnd(); advance(iterator)) {
         if (*iterator == ':') {
             m_url.m_userEnd = currentPosition(iterator);
             auto iteratorAtColon = iterator;
-            advance(iterator, authorityOrHostBegin);
+            ++iterator;
+            bool tabOrNewlineAfterColon = false;
+            while (UNLIKELY(!iterator.atEnd() && isTabOrNewline(*iterator))) {
+                tabOrNewlineAfterColon = true;
+                ++iterator;
+            }
             if (UNLIKELY(iterator.atEnd())) {
                 syntaxViolation(iteratorAtColon);
                 m_url.m_passwordEnd = m_url.m_userEnd;
@@ -1860,6 +1864,8 @@ void URLParser::parseAuthority(CodePointIterator<CharacterType> iterator)
                     appendToASCIIBuffer('@');
                 return;
             }
+            if (tabOrNewlineAfterColon)
+                syntaxViolation(iteratorAtColon);
             appendToASCIIBuffer(':');
             break;
         }
index fa96992..0192b43 100644 (file)
@@ -1,5 +1,15 @@
 2016-09-28  Alex Christensen  <achristensen@webkit.org>
 
+        URLParser should ignore tabs in authority
+        https://bugs.webkit.org/show_bug.cgi?id=162694
+
+        Reviewed by Geoffrey Garen.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
+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
 
index 434d428..d1ecd1c 100644 (file)
@@ -109,6 +109,12 @@ TEST_F(URLParserTest, Basic)
     checkURL("http://user:pass@webkit.org:123/", {"http", "user", "pass", "webkit.org", 123, "/", "", "", "http://user:pass@webkit.org:123/"});
     checkURL("http://user:pass@webkit.org:123", {"http", "user", "pass", "webkit.org", 123, "/", "", "", "http://user:pass@webkit.org:123/"});
     checkURL("http://user:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
+    checkURL("http://user:\t\t\tpass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
+    checkURL("http://us\ter:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
+    checkURL("http://user:pa\tss@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
+    checkURL("http://user:pass\t@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
+    checkURL("http://\tuser:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
+    checkURL("http://user\t:pass@webkit.org", {"http", "user", "pass", "webkit.org", 0, "/", "", "", "http://user:pass@webkit.org/"});
     checkURL("http://webkit.org", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"});
     checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
     checkURL("http://webkit.org/", {"http", "", "", "webkit.org", 0, "/", "", "", "http://webkit.org/"});
@@ -201,6 +207,7 @@ TEST_F(URLParserTest, Basic)
     checkURL("http://host?q=@ <>!#fragment", {"http", "", "", "host", 0, "/", "q=@%20%3C%3E!", "fragment", "http://host/?q=@%20%3C%3E!#fragment"});
     checkURL("http://user:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"});
     checkURL("http://user:@\thost", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"});
+    checkURL("http://user:\t@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"});
     checkURL("http://user\t:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"});
     checkURL("http://use\tr:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"});
     checkURL("http://127.0.0.1:10100/path", {"http", "", "", "127.0.0.1", 10100, "/path", "", "", "http://127.0.0.1:10100/path"});