Title: [205813] trunk
Revision
205813
Author
achristen...@apple.com
Date
2016-09-12 11:10:24 -0700 (Mon, 12 Sep 2016)

Log Message

Fix more URLParser quirks
https://bugs.webkit.org/show_bug.cgi?id=161834

Reviewed by Brady Eidson.

Source/WebCore:

Added new API tests.

* platform/URLParser.cpp:
(WebCore::URLParser::parse):
Skip some tabs and newlines.  The spec says to remove them before processing the String,
but to reduce allocations I am skipping them whenever we increment an iterator.
Fix a few other quirks to be more web platform conformant.

Tools:

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (205812 => 205813)


--- trunk/Source/WebCore/ChangeLog	2016-09-12 18:06:59 UTC (rev 205812)
+++ trunk/Source/WebCore/ChangeLog	2016-09-12 18:10:24 UTC (rev 205813)
@@ -1,3 +1,18 @@
+2016-09-12  Alex Christensen  <achristen...@webkit.org>
+
+        Fix more URLParser quirks
+        https://bugs.webkit.org/show_bug.cgi?id=161834
+
+        Reviewed by Brady Eidson.
+
+        Added new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+        Skip some tabs and newlines.  The spec says to remove them before processing the String,
+        but to reduce allocations I am skipping them whenever we increment an iterator.
+        Fix a few other quirks to be more web platform conformant.
+
 2016-09-09  Alex Christensen  <achristen...@webkit.org>
 
         Optimize URLParser performance

Modified: trunk/Source/WebCore/platform/URLParser.cpp (205812 => 205813)


--- trunk/Source/WebCore/platform/URLParser.cpp	2016-09-12 18:06:59 UTC (rev 205812)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2016-09-12 18:10:24 UTC (rev 205813)
@@ -559,11 +559,13 @@
                     m_url.m_portEnd = m_url.m_userStart;
                     auto maybeSlash = c;
                     ++maybeSlash;
+                    while (maybeSlash != end && isTabOrNewline(*maybeSlash))
+                        ++maybeSlash;
                     if (maybeSlash != end && *maybeSlash == '/') {
                         m_buffer.append('/');
                         m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
                         state = State::PathOrAuthority;
-                        ++c;
+                        c = maybeSlash;
                         ASSERT(*c == '/');
                     } else {
                         m_url.m_pathAfterLastSlash = m_url.m_userStart;
@@ -677,13 +679,13 @@
         case State::SpecialAuthoritySlashes:
             LOG_STATE("SpecialAuthoritySlashes");
             m_buffer.append("//");
-            if (*c == '/') {
+            if (*c == '/' || *c == '\\') {
                 ++c;
                 while (c != end && isTabOrNewline(*c))
                     ++c;
                 if (c == end)
                     return failure(input);
-                if (*c == '/')
+                if (*c == '/' || *c == '\\')
                     ++c;
             }
             state = State::SpecialAuthorityIgnoreSlashes;
@@ -925,7 +927,7 @@
                 m_url.m_queryEnd = m_url.m_pathEnd;
                 state = State::Fragment;
             } else {
-                m_buffer.append(*c);
+                utf8PercentEncode(*c, m_buffer, isInSimpleEncodeSet);
                 ++c;
             }
             break;

Modified: trunk/Tools/ChangeLog (205812 => 205813)


--- trunk/Tools/ChangeLog	2016-09-12 18:06:59 UTC (rev 205812)
+++ trunk/Tools/ChangeLog	2016-09-12 18:10:24 UTC (rev 205813)
@@ -1,3 +1,13 @@
+2016-09-12  Alex Christensen  <achristen...@webkit.org>
+
+        Fix more URLParser quirks
+        https://bugs.webkit.org/show_bug.cgi?id=161834
+
+        Reviewed by Brady Eidson.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2016-09-10  Alex Christensen  <achristen...@webkit.org>
 
         Optimize URLParser performance

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (205812 => 205813)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-12 18:06:59 UTC (rev 205812)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-12 18:10:24 UTC (rev 205813)
@@ -272,6 +272,10 @@
     checkRelativeURL("http:\\\\foo.com/", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"});
     checkRelativeURL("http:\\\\foo.com", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"});
     checkRelativeURL("http://ExAmPlE.CoM", "http://other.com", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
+    
+    // The checking of slashes in SpecialAuthoritySlashes needed to get this to pass contradicts what is in the spec,
+    // but it is included in the web platform tests.
+    checkRelativeURL("http:\\\\host\\foo", "about:blank", {"http", "", "", "host", 0, "/foo", "", "", "http://host/foo"});
 }
 
 static void checkURLDifferences(const String& urlString, const ExpectedParts& partsNew, const ExpectedParts& partsOld)
@@ -579,4 +583,14 @@
     shouldFail("?i", "sc:sd/sd");
 }
 
+// These are in the spec but not in the web platform tests.
+TEST_F(URLParserTest, AdditionalTests)
+{
+    checkURL("about:\a\aabc", {"about", "", "", "", 0, "%07%07abc", "", "", "about:%07%07abc"});
+    checkURL("notspecial:\t\t\n\t", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"});
+    checkURLDifferences("notspecial\t\t\n\t:\t\t\n\t/\t\t\n\t/\t\t\n\thost",
+        {"notspecial", "", "", "host", 0, "/", "", "", "notspecial://host/"},
+        {"notspecial", "", "", "host", 0, "", "", "", "notspecial://host"});
+}
+
 } // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to