URLParser should percent encode the user and password according to spec
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Sep 2016 18:59:01 +0000 (18:59 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Sep 2016 18:59:01 +0000 (18:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162049

Reviewed by Tim Horton.

Source/WebCore:

Covered by new API tests based on the web platform 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@206036 268f45cc-cd09-0410-ab3c-d52691b4dbfc

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

index 12d1d74..46f3ccf 100644 (file)
@@ -1,5 +1,17 @@
 2016-09-16  Alex Christensen  <achristensen@webkit.org>
 
+        URLParser should percent encode the user and password according to spec
+        https://bugs.webkit.org/show_bug.cgi?id=162049
+
+        Reviewed by Tim Horton.
+
+        Covered by new API tests based on the web platform tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parseAuthority):
+
+2016-09-16  Alex Christensen  <achristensen@webkit.org>
+
         Fix more edge cases in URLParser
         https://bugs.webkit.org/show_bug.cgi?id=162051
 
index 6681a1d..b1efc72 100644 (file)
@@ -1522,10 +1522,10 @@ void URLParser::parseAuthority(CodePointIterator<CharacterType> iterator)
             m_buffer.append(':');
             break;
         }
-        m_buffer.append(*iterator);
+        utf8PercentEncode(*iterator, m_buffer, isInUserInfoEncodeSet);
     }
     for (; !iterator.atEnd(); ++iterator)
-        m_buffer.append(*iterator);
+        utf8PercentEncode(*iterator, m_buffer, isInUserInfoEncodeSet);
     m_url.m_passwordEnd = m_buffer.length();
     if (!m_url.m_userEnd)
         m_url.m_userEnd = m_url.m_passwordEnd;
index c0168da..b72e457 100644 (file)
@@ -1,5 +1,15 @@
 2016-09-16  Alex Christensen  <achristensen@webkit.org>
 
+        URLParser should percent encode the user and password according to spec
+        https://bugs.webkit.org/show_bug.cgi?id=162049
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2016-09-16  Alex Christensen  <achristensen@webkit.org>
+
         Fix more edge cases in URLParser
         https://bugs.webkit.org/show_bug.cgi?id=162051
 
index 6e7c353..d82fadb 100644 (file)
@@ -498,6 +498,16 @@ TEST_F(URLParserTest, ParserDifferences)
     checkURLDifferences("http://host/path%2e.%2E",
         {"http", "", "", "host", 0, "/path...", "", "", "http://host/path..."},
         {"http", "", "", "host", 0, "/path%2e.%2E", "", "", "http://host/path%2e.%2E"});
+
+    checkRelativeURLDifferences(wideString(L"http://foo:💩@example.com/bar"), "http://other.com/",
+        {"http", "foo", wideString(L"💩"), "example.com", 0, "/bar", "", "", "http://foo:%F0%9F%92%A9@example.com/bar"},
+        {"", "", "", "", 0, "", "", "", wideString(L"http://foo:💩@example.com/bar")});
+    checkRelativeURLDifferences("http://&a:foo(b]c@d:2/", "http://example.org/foo/bar",
+        {"http", "&a", "foo(b]c", "d", 2, "/", "", "", "http://&a:foo(b%5Dc@d:2/"},
+        {"", "", "", "", 0, "", "", "", "http://&a:foo(b]c@d:2/"});
+    checkRelativeURLDifferences("http://`{}:`{}@h/`{}?`{}", "http://doesnotmatter/",
+        {"http", "`{}", "`{}", "h", 0, "/%60%7B%7D", "`{}", "", "http://%60%7B%7D:%60%7B%7D@h/%60%7B%7D?`{}"},
+        {"", "", "", "", 0, "", "", "", "http://`{}:`{}@h/`{}?`{}"});
 }
 
 TEST_F(URLParserTest, DefaultPort)