URLParser: correctly parse relative URLs that are just one character
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Sep 2016 18:00:19 +0000 (18:00 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Sep 2016 18:00:19 +0000 (18:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162344

Reviewed by Tim Horton.

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: https://svn.webkit.org/repository/webkit/trunk@206218 268f45cc-cd09-0410-ab3c-d52691b4dbfc

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

index 4977888..62f9ffd 100644 (file)
@@ -1,3 +1,15 @@
+2016-09-21  Alex Christensen  <achristensen@webkit.org>
+
+        URLParser: correctly parse relative URLs that are just one character
+        https://bugs.webkit.org/show_bug.cgi?id=162344
+
+        Reviewed by Tim Horton.
+
+        Covered by new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+
 2016-09-21  Daniel Bates  <dabates@apple.com>
 
         REGRESSION (r201090): Setting style.webkitTextSizeAdjust does not change text change on iPad
index ae03261..7f47a70 100644 (file)
@@ -998,7 +998,12 @@ URL URLParser::parse(const CharacterType* input, const unsigned length, const UR
             LOG_STATE("SchemeStart");
             if (isASCIIAlpha(*c)) {
                 m_asciiBuffer.uncheckedAppend(toASCIILower(*c));
-                ++c;
+                incrementIteratorSkippingTabAndNewLine<serialized>(c);
+                if (c.atEnd()) {
+                    m_asciiBuffer.clear();
+                    state = State::NoScheme;
+                    c = beginAfterControlAndSpace;
+                }
                 state = State::Scheme;
             } else
                 state = State::NoScheme;
index 15dcf3b..dcd9141 100644 (file)
@@ -1,3 +1,13 @@
+2016-09-21  Alex Christensen  <achristensen@webkit.org>
+
+        URLParser: correctly parse relative URLs that are just one character
+        https://bugs.webkit.org/show_bug.cgi?id=162344
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2016-09-20  Alex Christensen  <achristensen@webkit.org>
 
         Optimize URLParser
index 2aad924..847ae67 100644 (file)
@@ -296,6 +296,12 @@ TEST_F(URLParserTest, ParseRelative)
     checkRelativeURL("notspecial:", "about:blank", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"});
     checkRelativeURL("notspecial:", "http://host", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"});
     checkRelativeURL("http:", "http://host", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
+    checkRelativeURL("i", "sc:/pa/po", {"sc", "", "", "", 0, "/pa/i", "", "", "sc:/pa/i"});
+    checkRelativeURL("i    ", "sc:/pa/po", {"sc", "", "", "", 0, "/pa/i", "", "", "sc:/pa/i"});
+    checkRelativeURL("i\t\n  ", "sc:/pa/po", {"sc", "", "", "", 0, "/pa/i", "", "", "sc:/pa/i"});
+    checkRelativeURL("i", "sc://ho/pa", {"sc", "", "", "ho", 0, "/i", "", "", "sc://ho/i"});
+    checkRelativeURL("!", "sc://ho/pa", {"sc", "", "", "ho", 0, "/!", "", "", "sc://ho/!"});
+    checkRelativeURL("!", "sc:/ho/pa", {"sc", "", "", "", 0, "/ho/!", "", "", "sc:/ho/!"});
     
     // 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.