Changeset 206158 in webkit


Ignore:
Timestamp:
Sep 20, 2016 11:31:27 AM (8 years ago)
Author:
achristensen@apple.com
Message:

URLParser: Fix parsing relative URLs with one slash after the scheme:
https://bugs.webkit.org/show_bug.cgi?id=162294

Reviewed by Tim Horton.

Source/WebCore:

This fixes the relatively-obscure case where a relative URL has the same special scheme as the base,
but there is only one slash after the scheme: at the beginning of the relative URL. According to spec,
this should be interpreted the same as if the scheme: were not there.
For example, parsing "http:/example.com/" relative to "http://example.org/foo/bar" should be the same as
parsing "/example.com/" relative to "http://example.org/foo/bar".

Covered by a new API test.

  • platform/URLParser.cpp:

(WebCore::URLParser::parse):

Tools:

  • TestWebKitAPI/Tests/WebCore/URLParser.cpp:

(TestWebKitAPI::TEST_F):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206157 r206158  
     12016-09-20  Alex Christensen  <achristensen@webkit.org>
     2
     3        URLParser: Fix parsing relative URLs with one slash after the scheme:
     4        https://bugs.webkit.org/show_bug.cgi?id=162294
     5
     6        Reviewed by Tim Horton.
     7
     8        This fixes the relatively-obscure case where a relative URL has the same special scheme as the base,
     9        but there is only one slash after the scheme: at the beginning of the relative URL.  According to spec,
     10        this should be interpreted the same as if the scheme: were not there.
     11        For example, parsing "http:/example.com/" relative to "http://example.org/foo/bar" should be the same as
     12        parsing "/example.com/" relative to "http://example.org/foo/bar".
     13
     14        Covered by a new API test.
     15
     16        * platform/URLParser.cpp:
     17        (WebCore::URLParser::parse):
     18
    1192016-09-20  Alex Christensen  <achristensen@webkit.org>
    220
  • trunk/Source/WebCore/platform/URLParser.cpp

    r206157 r206158  
    10641064                    state = State::SpecialAuthorityIgnoreSlashes;
    10651065                    ++c;
    1066                 }
     1066                } else
     1067                    state = State::RelativeSlash;
    10671068            } else
    10681069                state = State::Relative;
  • trunk/Tools/ChangeLog

    r206157 r206158  
     12016-09-20  Alex Christensen  <achristensen@webkit.org>
     2
     3        URLParser: Fix parsing relative URLs with one slash after the scheme:
     4        https://bugs.webkit.org/show_bug.cgi?id=162294
     5
     6        Reviewed by Tim Horton.
     7
     8        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
     9        (TestWebKitAPI::TEST_F):
     10
    1112016-09-20  Alex Christensen  <achristensen@webkit.org>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp

    r206157 r206158  
    475475        {"http", "", "", "", 0, "", "", "", "http:"},
    476476        {"http", "", "", "", 0, "/", "", "", "http:/"});
     477    checkRelativeURLDifferences("http:/example.com/", "http://example.org/foo/bar",
     478        {"http", "", "", "example.org", 0, "/example.com/", "", "", "http://example.org/example.com/"},
     479        {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
    477480   
    478481    // This behavior matches Chrome and Firefox, but not WebKit using URL::parse.
Note: See TracChangeset for help on using the changeset viewer.