Title: [205782] trunk
Revision
205782
Author
achristen...@apple.com
Date
2016-09-09 19:06:39 -0700 (Fri, 09 Sep 2016)

Log Message

URLParser: Keep track of cannot-be-a-base-url according to spec
https://bugs.webkit.org/show_bug.cgi?id=161830

Reviewed by Tim Horton.

Source/WebCore:

Covered by new API tests.

* platform/URL.cpp:
(WebCore::URL::invalidate):
* platform/URL.h:
Add a boolean required by the spec.
This will not add to sizeof(URL) because we already have some bit fields.
* platform/URLParser.cpp:
(WebCore::URLParser::parse):
(WebCore::URLParser::allValuesEqual):

Tools:

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (205781 => 205782)


--- trunk/Source/WebCore/ChangeLog	2016-09-10 01:08:23 UTC (rev 205781)
+++ trunk/Source/WebCore/ChangeLog	2016-09-10 02:06:39 UTC (rev 205782)
@@ -1,3 +1,21 @@
+2016-09-09  Alex Christensen  <achristen...@webkit.org>
+
+        URLParser: Keep track of cannot-be-a-base-url according to spec
+        https://bugs.webkit.org/show_bug.cgi?id=161830
+
+        Reviewed by Tim Horton.
+
+        Covered by new API tests.
+
+        * platform/URL.cpp:
+        (WebCore::URL::invalidate):
+        * platform/URL.h:
+        Add a boolean required by the spec.
+        This will not add to sizeof(URL) because we already have some bit fields.
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+        (WebCore::URLParser::allValuesEqual):
+
 2016-09-09  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r205771.

Modified: trunk/Source/WebCore/platform/URL.cpp (205781 => 205782)


--- trunk/Source/WebCore/platform/URL.cpp	2016-09-10 01:08:23 UTC (rev 205781)
+++ trunk/Source/WebCore/platform/URL.cpp	2016-09-10 02:06:39 UTC (rev 205782)
@@ -425,6 +425,7 @@
 {
     m_isValid = false;
     m_protocolIsInHTTPFamily = false;
+    m_cannotBeABaseURL = false;
     m_schemeEnd = 0;
     m_userStart = 0;
     m_userEnd = 0;

Modified: trunk/Source/WebCore/platform/URL.h (205781 => 205782)


--- trunk/Source/WebCore/platform/URL.h	2016-09-10 01:08:23 UTC (rev 205781)
+++ trunk/Source/WebCore/platform/URL.h	2016-09-10 02:06:39 UTC (rev 205782)
@@ -218,6 +218,7 @@
     String m_string;
     bool m_isValid : 1;
     bool m_protocolIsInHTTPFamily : 1;
+    bool m_cannotBeABaseURL : 1;
 
     unsigned m_schemeEnd;
     unsigned m_userStart;

Modified: trunk/Source/WebCore/platform/URLParser.cpp (205781 => 205782)


--- trunk/Source/WebCore/platform/URLParser.cpp	2016-09-10 01:08:23 UTC (rev 205781)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2016-09-10 02:06:39 UTC (rev 205782)
@@ -476,6 +476,7 @@
                         ASSERT(*c == '/');
                     } else {
                         m_url.m_pathAfterLastSlash = m_url.m_userStart;
+                        m_url.m_cannotBeABaseURL = true;
                         state = State::CannotBeABaseURLPath;
                     }
                     ++c;
@@ -498,19 +499,21 @@
             break;
         case State::NoScheme:
             LOG_STATE("NoScheme");
-            if (base.isNull()) {
-                if (*c == '#') {
-                    copyURLPartsUntil(base, URLPart::QueryEnd);
-                    state = State::Fragment;
-                    ++c;
-                } else
-                    return failure(input);
-            } else if (base.protocol() == "file") {
-                copyURLPartsUntil(base, URLPart::SchemeEnd);
-                m_buffer.append(':');
-                state = State::File;
-            } else
+            if (base.isNull() || (base.m_cannotBeABaseURL && *c != '#'))
+                return failure(input);
+            if (base.m_cannotBeABaseURL && *c == '#') {
+                copyURLPartsUntil(base, URLPart::QueryEnd);
+                state = State::Fragment;
+                ++c;
+                break;
+            }
+            if (base.protocol() != "file") {
                 state = State::Relative;
+                break;
+            }
+            copyURLPartsUntil(base, URLPart::SchemeEnd);
+            m_buffer.append(':');
+            state = State::File;
             break;
         case State::SpecialRelativeOrAuthority:
             LOG_STATE("SpecialRelativeOrAuthority");
@@ -1476,6 +1479,8 @@
 
 bool URLParser::allValuesEqual(const URL& a, const URL& b)
 {
+    // FIXME: m_cannotBeABaseURL is not compared because the old URL::parse did not use it,
+    // but once we get rid of URL::parse its value should be tested.
     LOG(URLParser, "%d %d %d %d %d %d %d %d %d %d %d %d %s\n%d %d %d %d %d %d %d %d %d %d %d %d %s",
         a.m_isValid,
         a.m_protocolIsInHTTPFamily,

Modified: trunk/Tools/ChangeLog (205781 => 205782)


--- trunk/Tools/ChangeLog	2016-09-10 01:08:23 UTC (rev 205781)
+++ trunk/Tools/ChangeLog	2016-09-10 02:06:39 UTC (rev 205782)
@@ -1,5 +1,15 @@
 2016-09-09  Alex Christensen  <achristen...@webkit.org>
 
+        URLParser: Keep track of cannot-be-a-base-url according to spec
+        https://bugs.webkit.org/show_bug.cgi?id=161830
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2016-09-09  Alex Christensen  <achristen...@webkit.org>
+
         Fix API tests after r205774.
         https://bugs.webkit.org/show_bug.cgi?id=161820
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (205781 => 205782)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-10 01:08:23 UTC (rev 205781)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-10 02:06:39 UTC (rev 205782)
@@ -563,6 +563,12 @@
     shouldFail("http://:b@");
     shouldFail("http://@");
     shouldFail("http://[0:f::f:f:0:0]:abc");
+    shouldFail("../i", "sc:sd");
+    shouldFail("../i", "sc:sd/sd");
+    shouldFail("/i", "sc:sd");
+    shouldFail("/i", "sc:sd/sd");
+    shouldFail("?i", "sc:sd");
+    shouldFail("?i", "sc:sd/sd");
 }
 
 } // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to