URLParser should allow '@' in user
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Sep 2016 18:34:19 +0000 (18:34 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Sep 2016 18:34:19 +0000 (18:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162272

Reviewed by Tim Horton.

Source/WebCore:

Covered by a new API test.

* platform/URLParser.cpp:
(WebCore::URLParser::parse):
The spec describes using an "@ flag" and rewinding iterators.  I've implemented the authority parsing
and host parsing a little differently, but this makes it equivalent.

Tools:

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

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

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

index a2fd47e..52a0ab9 100644 (file)
@@ -1,5 +1,19 @@
 2016-09-20  Alex Christensen  <achristensen@webkit.org>
 
+        URLParser should allow '@' in user
+        https://bugs.webkit.org/show_bug.cgi?id=162272
+
+        Reviewed by Tim Horton.
+
+        Covered by a new API test.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+        The spec describes using an "@ flag" and rewinding iterators.  I've implemented the authority parsing
+        and host parsing a little differently, but this makes it equivalent.
+
+2016-09-20  Alex Christensen  <achristensen@webkit.org>
+
         URLParser: Fix parsing relative URLs with one slash after the scheme:
         https://bugs.webkit.org/show_bug.cgi?id=162294
 
index 0480bad..81196fe 100644 (file)
@@ -1143,7 +1143,15 @@ URL URLParser::parse(const CharacterType* input, const unsigned length, const UR
             LOG_STATE("AuthorityOrHost");
             {
                 if (*c == '@') {
-                    parseAuthority<serialized>(CodePointIterator<CharacterType>(authorityOrHostBegin, c));
+                    auto lastAt = c;
+                    auto findLastAt = c;
+                    while (!findLastAt.atEnd()) {
+                        if (*findLastAt == '@')
+                            lastAt = findLastAt;
+                        ++findLastAt;
+                    }
+                    parseAuthority<serialized>(CodePointIterator<CharacterType>(authorityOrHostBegin, lastAt));
+                    c = lastAt;
                     incrementIteratorSkippingTabAndNewLine<serialized>(c);
                     authorityOrHostBegin = c;
                     state = State::Host;
index ff935ef..d86c7dc 100644 (file)
@@ -1,5 +1,15 @@
 2016-09-20  Alex Christensen  <achristensen@webkit.org>
 
+        URLParser should allow '@' in user
+        https://bugs.webkit.org/show_bug.cgi?id=162272
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2016-09-20  Alex Christensen  <achristensen@webkit.org>
+
         URLParser: Fix parsing relative URLs with one slash after the scheme:
         https://bugs.webkit.org/show_bug.cgi?id=162294
 
index 5291a47..abdae75 100644 (file)
@@ -544,6 +544,9 @@ TEST_F(URLParserTest, ParserDifferences)
     checkRelativeURLDifferences("/C|/foo/bar", "file:///tmp/mock/path",
         {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"},
         {"file", "", "", "", 0, "/C|/foo/bar", "", "", "file:///C|/foo/bar"});
+    checkRelativeURLDifferences("https://@test@test@example:800/", "http://doesnotmatter/",
+        {"https", "@test@test", "", "example", 800, "/", "", "", "https://%40test%40test@example:800/"},
+        {"", "", "", "", 0, "", "", "", "https://@test@test@example:800/"});
 }
 
 TEST_F(URLParserTest, DefaultPort)