[URLParser] Fix file URLs that are just file:// and a Windows drive letter
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Mar 2017 23:07:56 +0000 (23:07 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Mar 2017 23:07:56 +0000 (23:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169242

Patch by Alex Christensen <achristensen@webkit.org> on 2017-03-07
Reviewed by Tim Horton.

LayoutTests/imported/w3c:

* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/url-constructor-expected.txt:

Source/WebCore:

This is specified in https://url.spec.whatwg.org/#file-host-state and tested by a newly-passing
web platform test.  I added the check for the windows drive quirk in the FileHost state of the
parser but I forgot it when FileHost is the terminal state.

* 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@213546 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt
LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/URLParser.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp

index 586f4bb..5f669ba 100644 (file)
@@ -1,3 +1,14 @@
+2017-03-07  Alex Christensen  <achristensen@webkit.org>
+
+        [URLParser] Fix file URLs that are just file:// and a Windows drive letter
+        https://bugs.webkit.org/show_bug.cgi?id=169242
+
+        Reviewed by Tim Horton.
+
+        * web-platform-tests/url/a-element-expected.txt:
+        * web-platform-tests/url/a-element-xhtml-expected.txt:
+        * web-platform-tests/url/url-constructor-expected.txt:
+
 2017-03-07  Youenn Fablet  <youenn@apple.com>
 
         W3C importer should be able to update the import expectations file
index f73490e..a78a1c0 100644 (file)
@@ -386,7 +386,7 @@ PASS Parsing: <pix/submit.gif> against <file:///C:/Users/Domenic/Dropbox/GitHub/
 PASS Parsing: <..> against <file:///C:/> 
 PASS Parsing: <..> against <file:///> 
 PASS Parsing: </> against <file:///C:/a/b> 
-FAIL Parsing: <//d:> against <file:///C:/a/b> assert_equals: href expected "file:///d:" but got "file://d/"
+PASS Parsing: <//d:> against <file:///C:/a/b> 
 PASS Parsing: <//d:/..> against <file:///C:/a/b> 
 PASS Parsing: <..> against <file:///ab:/> 
 PASS Parsing: <..> against <file:///1:/> 
index f73490e..a78a1c0 100644 (file)
@@ -386,7 +386,7 @@ PASS Parsing: <pix/submit.gif> against <file:///C:/Users/Domenic/Dropbox/GitHub/
 PASS Parsing: <..> against <file:///C:/> 
 PASS Parsing: <..> against <file:///> 
 PASS Parsing: </> against <file:///C:/a/b> 
-FAIL Parsing: <//d:> against <file:///C:/a/b> assert_equals: href expected "file:///d:" but got "file://d/"
+PASS Parsing: <//d:> against <file:///C:/a/b> 
 PASS Parsing: <//d:/..> against <file:///C:/a/b> 
 PASS Parsing: <..> against <file:///ab:/> 
 PASS Parsing: <..> against <file:///1:/> 
index a01e4b2..b4c13ee 100644 (file)
@@ -394,7 +394,7 @@ PASS Parsing: <pix/submit.gif> against <file:///C:/Users/Domenic/Dropbox/GitHub/
 PASS Parsing: <..> against <file:///C:/> 
 PASS Parsing: <..> against <file:///> 
 PASS Parsing: </> against <file:///C:/a/b> 
-FAIL Parsing: <//d:> against <file:///C:/a/b> assert_equals: href expected "file:///d:" but got "file://d/"
+PASS Parsing: <//d:> against <file:///C:/a/b> 
 PASS Parsing: <//d:/..> against <file:///C:/a/b> 
 PASS Parsing: <..> against <file:///ab:/> 
 PASS Parsing: <..> against <file:///1:/> 
index f466c39..30dc3a0 100644 (file)
@@ -1,3 +1,17 @@
+2017-03-07  Alex Christensen  <achristensen@webkit.org>
+
+        [URLParser] Fix file URLs that are just file:// and a Windows drive letter
+        https://bugs.webkit.org/show_bug.cgi?id=169242
+
+        Reviewed by Tim Horton.
+
+        This is specified in https://url.spec.whatwg.org/#file-host-state and tested by a newly-passing
+        web platform test.  I added the check for the windows drive quirk in the FileHost state of the
+        parser but I forgot it when FileHost is the terminal state.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+
 2017-03-07  Chris Dumez  <cdumez@apple.com>
 
         Drop non-standard MessageEvent.webkitInitMessageEvent()
index 885e85f..d1f8fe8 100644 (file)
@@ -1957,6 +1957,18 @@ void URLParser::parse(const CharacterType* input, const unsigned length, const U
         break;
     case State::FileHost:
         LOG_FINAL_STATE("FileHost");
+        if (takesTwoAdvancesUntilEnd(CodePointIterator<CharacterType>(authorityOrHostBegin, c))
+            && isWindowsDriveLetter(authorityOrHostBegin)) {
+            syntaxViolation(authorityOrHostBegin);
+            appendToASCIIBuffer('/');
+            appendWindowsDriveLetter(authorityOrHostBegin);
+            m_url.m_pathAfterLastSlash = currentPosition(c);
+            m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
+            m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
+            m_url.m_fragmentEnd = m_url.m_pathAfterLastSlash;
+            break;
+        }
+        
         if (authorityOrHostBegin == c) {
             syntaxViolation(c);
             appendToASCIIBuffer('/');
index 41bfe45..77074f9 100644 (file)
@@ -1,3 +1,13 @@
+2017-03-07  Alex Christensen  <achristensen@webkit.org>
+
+        [URLParser] Fix file URLs that are just file:// and a Windows drive letter
+        https://bugs.webkit.org/show_bug.cgi?id=169242
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2017-03-07  Jonathan Bedard  <jbedard@apple.com>
 
         Standardize device/simulator naming conventions
index d3e4080..e4fdcba 100644 (file)
@@ -584,6 +584,9 @@ TEST_F(URLParserTest, ParseRelative)
     checkRelativeURL("/abc", "file:///C:/a/b", {"file", "", "", "", 0, "/C:/abc", "", "", "file:///C:/abc"});
     checkRelativeURL("/abc", "file:///C:", {"file", "", "", "", 0, "/C:/abc", "", "", "file:///C:/abc"});
     checkRelativeURL("/abc", "file:///", {"file", "", "", "", 0, "/abc", "", "", "file:///abc"});
+    checkRelativeURL("//d:", "file:///C:/a/b", {"file", "", "", "", 0, "/d:", "", "", "file:///d:"}, TestTabs::No);
+    checkRelativeURL("//d|", "file:///C:/a/b", {"file", "", "", "", 0, "/d:", "", "", "file:///d:"}, TestTabs::No);
+    checkRelativeURL("//A|", "file:///C:/a/b", {"file", "", "", "", 0, "/A:", "", "", "file:///A:"}, TestTabs::No);
 
     // 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.