URLParser: Correctly ignore spaces before relative URLs with no scheme
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Sep 2016 01:25:08 +0000 (01:25 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Sep 2016 01:25:08 +0000 (01:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161889

Reviewed by Daniel Bates.

Source/WebCore:

Covered by new API tests.

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

Tools:

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

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

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

index 3aac55e..aba8af1 100644 (file)
@@ -1,3 +1,15 @@
+2016-09-12  Alex Christensen  <achristensen@webkit.org>
+
+        URLParser: Correctly ignore spaces before relative URLs with no scheme
+        https://bugs.webkit.org/show_bug.cgi?id=161889
+
+        Reviewed by Daniel Bates.
+
+        Covered by new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+
 2016-09-12  Nan Wang  <n_wang@apple.com>
 
         AX: Crash at WebCore::Range::compareBoundaryPoints(WebCore::Range::CompareHow, WebCore::Range const&, int&) const + 23
index cbf8152..2195413 100644 (file)
@@ -490,6 +490,7 @@ URL URLParser::parse(const String& input, const URL& base, const TextEncoding& e
     auto authorityOrHostBegin = codePoints.begin();
     while (c != end && isC0ControlOrSpace(*c))
         ++c;
+    auto beginAfterControlAndSpace = c;
     
     enum class State : uint8_t {
         SchemeStart,
@@ -582,7 +583,7 @@ URL URLParser::parse(const String& input, const URL& base, const TextEncoding& e
             } else {
                 m_buffer.clear();
                 state = State::NoScheme;
-                c = codePoints.begin();
+                c = beginAfterControlAndSpace;
                 break;
             }
             ++c;
@@ -591,7 +592,7 @@ URL URLParser::parse(const String& input, const URL& base, const TextEncoding& e
             if (c == end) {
                 m_buffer.clear();
                 state = State::NoScheme;
-                c = codePoints.begin();
+                c = beginAfterControlAndSpace;
             }
             break;
         case State::NoScheme:
index ee68652..e591dea 100644 (file)
@@ -1,5 +1,15 @@
 2016-09-12  Alex Christensen  <achristensen@webkit.org>
 
+        URLParser: Correctly ignore spaces before relative URLs with no scheme
+        https://bugs.webkit.org/show_bug.cgi?id=161889
+
+        Reviewed by Daniel Bates.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2016-09-12  Alex Christensen  <achristensen@webkit.org>
+
         URLParser: Fix relative URLs containing only fragments
         https://bugs.webkit.org/show_bug.cgi?id=161882
 
index fd7a637..cc7b6b9 100644 (file)
@@ -277,6 +277,8 @@ TEST_F(URLParserTest, ParseRelative)
     checkRelativeURL("http:", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"});
     checkRelativeURL("#x", "data:,", {"data", "", "", "", 0, ",", "", "x", "data:,#x"});
     checkRelativeURL("#x", "about:blank", {"about", "", "", "", 0, "blank", "", "x", "about:blank#x"});
+    checkRelativeURL("  foo.com  ", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/foo.com", "", "", "http://example.org/foo/foo.com"});
+    checkRelativeURL(" \a baz", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/baz", "", "", "http://example.org/foo/baz"});
     
     // 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.