Changeset 205667 in webkit


Ignore:
Timestamp:
Sep 8, 2016 3:15:07 PM (8 years ago)
Author:
achristensen@apple.com
Message:

URLParser should handle URLs with empty authority
https://bugs.webkit.org/show_bug.cgi?id=161711

Reviewed by Brady Eidson.

Source/WebCore:

Covered by new API tests.

  • platform/URLParser.cpp:

(WebCore::URLParser::parse):
(WebCore::URLParser::parseAuthority):

Tools:

  • TestWebKitAPI/Tests/WebCore/URLParser.cpp:

(TestWebKitAPI::TEST_F):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r205665 r205667  
     12016-09-08  Alex Christensen  <achristensen@webkit.org>
     2
     3        URLParser should handle URLs with empty authority
     4        https://bugs.webkit.org/show_bug.cgi?id=161711
     5
     6        Reviewed by Brady Eidson.
     7
     8        Covered by new API tests.
     9
     10        * platform/URLParser.cpp:
     11        (WebCore::URLParser::parse):
     12        (WebCore::URLParser::parseAuthority):
     13
    1142016-09-08  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Source/WebCore/platform/URLParser.cpp

    r205650 r205667  
    858858    case State::SpecialAuthorityIgnoreSlashes:
    859859        LOG_FINAL_STATE("SpecialAuthorityIgnoreSlashes");
    860         break;
     860        return { };
    861861    case State::AuthorityOrHost:
    862862        LOG_FINAL_STATE("AuthorityOrHost");
     
    975975void URLParser::parseAuthority(StringView::CodePoints::Iterator& iterator, const StringView::CodePoints::Iterator& end)
    976976{
     977    if (iterator == end) {
     978        m_url.m_userEnd = m_buffer.length();
     979        m_url.m_passwordEnd = m_url.m_userEnd;
     980        return;
     981    }
    977982    for (; iterator != end; ++iterator) {
    978         m_buffer.append(*iterator);
    979983        if (*iterator == ':') {
    980984            ++iterator;
    981             m_url.m_userEnd = m_buffer.length() - 1;
    982             break;
    983         }
     985            m_url.m_userEnd = m_buffer.length();
     986            if (iterator == end) {
     987                m_url.m_passwordEnd = m_url.m_userEnd;
     988                if (m_url.m_userEnd > m_url.m_userStart)
     989                    m_buffer.append('@');
     990                return;
     991            }
     992            m_buffer.append(':');
     993            break;
     994        }
     995        m_buffer.append(*iterator);
    984996    }
    985997    for (; iterator != end; ++iterator)
  • trunk/Tools/ChangeLog

    r205650 r205667  
     12016-09-08  Alex Christensen  <achristensen@webkit.org>
     2
     3        URLParser should handle URLs with empty authority
     4        https://bugs.webkit.org/show_bug.cgi?id=161711
     5
     6        Reviewed by Brady Eidson.
     7
     8        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
     9        (TestWebKitAPI::TEST_F):
     10
    1112016-09-08  Alex Christensen  <achristensen@webkit.org>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp

    r205650 r205667  
    179179    checkURL("http://host/a%20B", {"http", "", "", "host", 0, "/a%20B", "", "", "http://host/a%20B"});
    180180    checkURL("http://host?q=@ <>!#fragment", {"http", "", "", "host", 0, "/", "q=@%20%3C%3E!", "fragment", "http://host/?q=@%20%3C%3E!#fragment"});
     181    checkURL("http://user:@host", {"http", "user", "", "host", 0, "/", "", "", "http://user@host/"});
     182
     183    // This disagrees with the web platform test for http://:@www.example.com but agrees with Chrome and URL::parse,
     184    // and Firefox fails the web platform test differently. Maybe the web platform test ought to be changed.
     185    checkURL("http://:@host", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
    181186}
    182187
     
    231236    checkRelativeURL("#?", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "?", "http://example.org/foo/bar#?"});
    232237    checkRelativeURL("/", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/", "", "", "http://example.org/"});
     238    checkRelativeURL("http://@host", "about:blank", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
     239    checkRelativeURL("http://:@host", "about:blank", {"http", "", "", "host", 0, "/", "", "", "http://host/"});
    233240}
    234241
     
    355362        {"http", "", "", "example.org", 0, "/foo/bar", "", wideString(L"β"), wideString(L"http://example.org/foo/bar#β")},
    356363        {"http", "", "", "example.org", 0, "/foo/bar", "", "%CE%B2", "http://example.org/foo/bar#%CE%B2"});
    357 
    358     // FIXME: This behavior ought to be specified in the standard.
    359     // With the existing URL::parse, WebKit returns "https:/", Firefox returns "https:///", and Chrome throws an error.
     364    checkURLDifferences("http://@",
     365        {"", "", "", "", 0, "", "", "", ""},
     366        {"", "", "", "", 0, "", "", "", "http://@"});
     367    checkURLDifferences("http://",
     368        {"", "", "", "", 0, "", "", "", ""},
     369        {"http", "", "", "", 0, "/", "", "", "http:/"});
    360370    checkRelativeURLDifferences("//", "https://www.webkit.org/path",
    361         {"https", "", "", "", 0, "", "", "", "https://"},
     371        {"", "", "", "", 0, "", "", "", ""},
    362372        {"https", "", "", "", 0, "/", "", "", "https:/"});
    363373   
     
    437447   
    438448    // FIXME: Fix and check unknown schemes with ports, as well as ftps.
     449
     450    // Firefox returns http://a:@/ Chrome fails, URL::parse fails
     451    checkRelativeURLDifferences("http://a:@", "about:blank",
     452        {"", "", "", "", 0, "", "", "", ""},
     453        {"", "", "", "", 0, "", "", "", "http://a:@"});
     454   
     455    checkRelativeURLDifferences("http://:@", "about:blank",
     456        {"", "", "", "", 0, "", "", "", ""},
     457        {"", "", "", "", 0, "", "", "", "http://:@"});
     458    checkRelativeURLDifferences("http://:b@", "about:blank",
     459        {"", "", "", "", 0, "", "", "", ""},
     460        {"", "", "", "", 0, "", "", "", "http://:b@"});
     461    checkURLDifferences("http://a:@",
     462        {"", "", "", "", 0, "", "", "", ""},
     463        {"", "", "", "", 0, "", "", "", "http://a:@"});
     464    checkURLDifferences("http://:b@",
     465        {"", "", "", "", 0, "", "", "", ""},
     466        {"", "", "", "", 0, "", "", "", "http://:b@"});
    439467}
    440468   
Note: See TracChangeset for help on using the changeset viewer.