Changeset 78383 in webkit


Ignore:
Timestamp:
Feb 11, 2011 3:47:06 PM (13 years ago)
Author:
eric@webkit.org
Message:

2011-02-11 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

KURL should remove default port numbers when cannonicalizing urls (to match every other browser)
https://bugs.webkit.org/show_bug.cgi?id=54090

Added a new test to show that we are intentionally removing
a colon after a host name. http://foo.com:/ -> http://foo.com/

  • fast/url/port-expected.txt:
  • fast/url/relative-unix-expected.txt:
  • fast/url/segments-expected.txt:
  • fast/url/segments-from-data-url-expected.txt:
  • fast/url/standard-url-expected.txt:

2011-02-11 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

KURL should remove default port numbers when cannonicalizing urls (to match every other browser)
https://bugs.webkit.org/show_bug.cgi?id=54090

  • platform/KURL.cpp: (WebCore::isDefaultPortForScheme): (WebCore::KURL::parse):
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r78374 r78383  
     12011-02-11  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        KURL should remove default port numbers when cannonicalizing urls (to match every other browser)
     6        https://bugs.webkit.org/show_bug.cgi?id=54090
     7
     8        Added a new test to show that we are intentionally removing
     9        a colon after a host name.  http://foo.com:/ -> http://foo.com/
     10
     11        * fast/url/port-expected.txt:
     12        * fast/url/relative-unix-expected.txt:
     13        * fast/url/segments-expected.txt:
     14        * fast/url/segments-from-data-url-expected.txt:
     15        * fast/url/standard-url-expected.txt:
     16
    1172011-02-11  Mihai Parparita  <mihaip@chromium.org>
    218
  • trunk/LayoutTests/fast/url/port-expected.txt

    r57588 r78383  
    66FAIL canonicalize('http://www.example.com:as df/') should be http://www.example.com:as%20df/. Was http://www.example.com:as df/.
    77PASS canonicalize('http://www.example.com:-2/') is 'http://www.example.com:-2/'
    8 FAIL canonicalize('http://www.example.com:80/') should be http://www.example.com/. Was http://www.example.com:80/.
     8PASS canonicalize('http://www.example.com:80/') is 'http://www.example.com/'
    99PASS canonicalize('http://www.example.com:8080/') is 'http://www.example.com:8080/'
     10PASS canonicalize('http://www.example.com:/') is 'http://www.example.com/'
    1011PASS canonicalize('foobar://www.example.com:80/') is 'foobar://www.example.com:80/'
    1112PASS successfullyParsed is true
  • trunk/LayoutTests/fast/url/relative-unix-expected.txt

    r78044 r78383  
    66PASS canonicalize('\\\\Another\\path') is 'http://another/path'
    77PASS canonicalize('/c:\\foo') is 'http://host/c:/foo'
    8 FAIL canonicalize('//c:\\foo') should be http://c/foo. Was http://c:/foo.
     8PASS canonicalize('//c:\\foo') is 'http://c/foo'
    99PASS successfullyParsed is true
    1010
  • trunk/LayoutTests/fast/url/relative-win-expected.txt

    r57785 r78383  
    99FAIL canonicalize('/../bar.html') should be file:///C:/bar.html. Was file:///bar.html.
    1010FAIL canonicalize('\\\\another\\path') should be . Was http://another/path.
    11 FAIL canonicalize('//c:/foo') should be file:///C:/foo. Was file://c:/foo.
     11FAIL canonicalize('//c:/foo') should be file:///C:/foo. Was file://c/foo.
    1212FAIL canonicalize('//localhost/c:/foo') should be file:///C:/foo. Was file:///c:/foo.
    1313FAIL canonicalize('c:') should be . Was c:.
  • trunk/LayoutTests/fast/url/script-tests/port.js

    r57588 r78383  
    88  ["80", ""],
    99  ["8080", ":8080"],
     10  // Empty ports (just a colon) should also be removed
     11  ["", ""],
    1012];
    1113
  • trunk/LayoutTests/fast/url/segments-expected.txt

    r78040 r78383  
    6868PASS segments('http://2001::1]:80') is '[":","","0","","",""]'
    6969PASS segments('http://[2001::1]') is '["http:","[2001::1]","0","/","",""]'
    70 FAIL segments('http://[2001::1]:80') should be ["http:","[2001::1]","0","/","",""]. Was ["http:","[2001::1]","80","/","",""].
     70PASS segments('http://[2001::1]:80') is '["http:","[2001::1]","0","/","",""]'
    7171PASS segments('http://[[::]]') is '[":","","0","","",""]'
    7272PASS successfullyParsed is true
  • trunk/LayoutTests/fast/url/segments-from-data-url-expected.txt

    r78040 r78383  
    6868PASS segments('http://2001::1]:80') is '[":","","0","","",""]'
    6969PASS segments('http://[2001::1]') is '["http:","[2001::1]","0","/","",""]'
    70 FAIL segments('http://[2001::1]:80') should be ["http:","[2001::1]","0","/","",""]. Was ["http:","[2001::1]","80","/","",""].
     70PASS segments('http://[2001::1]:80') is '["http:","[2001::1]","0","/","",""]'
    7171PASS segments('http://[[::]]') is '[":","","0","","",""]'
    7272PASS successfullyParsed is true
  • trunk/LayoutTests/fast/url/standard-url-expected.txt

    r78044 r78383  
    1313PASS canonicalize('http:\\\\www.google.com\\foo') is 'http://www.google.com/foo'
    1414FAIL canonicalize('http://www.google.com/asdf#\ud800') should be http://www.google.com/asdf#�. Was http://www.google.com/asdf#%26%2355296%3B.
    15 FAIL canonicalize('http://foo:80/') should be http://foo/. Was http://foo:80/.
     15PASS canonicalize('http://foo:80/') is 'http://foo/'
    1616PASS canonicalize('http://foo:81/') is 'http://foo:81/'
    1717PASS canonicalize('httpa://foo:80/') is 'httpa://foo:80/'
    1818PASS canonicalize('http://foo:-80/') is 'http://foo:-80/'
    19 FAIL canonicalize('https://foo:443/') should be https://foo/. Was https://foo:443/.
     19PASS canonicalize('https://foo:443/') is 'https://foo/'
    2020PASS canonicalize('https://foo:80/') is 'https://foo:80/'
    21 FAIL canonicalize('ftp://foo:21/') should be ftp://foo/. Was ftp://foo:21/.
     21PASS canonicalize('ftp://foo:21/') is 'ftp://foo/'
    2222PASS canonicalize('ftp://foo:80/') is 'ftp://foo:80/'
    23 FAIL canonicalize('gopher://foo:70/') should be gopher://foo/. Was gopher://foo:70/.
     23PASS canonicalize('gopher://foo:70/') is 'gopher://foo/'
    2424PASS canonicalize('gopher://foo:443/') is 'gopher://foo:443/'
    25 FAIL canonicalize('ws://foo:80/') should be ws://foo/. Was ws://foo:80/.
     25PASS canonicalize('ws://foo:80/') is 'ws://foo/'
    2626PASS canonicalize('ws://foo:81/') is 'ws://foo:81/'
    2727PASS canonicalize('ws://foo:443/') is 'ws://foo:443/'
     
    2929PASS canonicalize('wss://foo:80/') is 'wss://foo:80/'
    3030PASS canonicalize('wss://foo:81/') is 'wss://foo:81/'
    31 FAIL canonicalize('wss://foo:443/') should be wss://foo/. Was wss://foo:443/.
     31PASS canonicalize('wss://foo:443/') is 'wss://foo/'
    3232PASS canonicalize('wss://foo:815/') is 'wss://foo:815/'
    3333PASS successfullyParsed is true
  • trunk/LayoutTests/platform/mac/http/tests/inspector/console-websocket-error-expected.txt

    r74611 r78383  
    66
    77console-websocket-error.html:32testDNSLookup: Test started.
    8 ws://nonexistent.domain.invalid:80/WebSocket network error: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 2.)
     8ws://nonexistent.domain.invalid/WebSocket network error: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 2.)
    99console-websocket-error.html:43testDNSLookup: onclose is called.
    1010console-websocket-error.html:50testSSLCertificate: Test started.
  • trunk/LayoutTests/platform/mac/security/block-test-expected.txt

    r74453 r78383  
    138138http://255.255.255.255:0/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:0/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
    139139http://255.255.255.255:0/test.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://255.255.255.255:0/test.jpg">
    140 http://255.255.255.255:80/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:80/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
    141 http://255.255.255.255:80/test.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://255.255.255.255:80/test.jpg">
    142 http://255.255.255.255:/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
    143 http://255.255.255.255:/test.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://255.255.255.255:/test.jpg">
     140http://255.255.255.255/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
     141http://255.255.255.255/test.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://255.255.255.255/test.jpg">
     142http://255.255.255.255/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
     143http://255.255.255.255/test.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://255.255.255.255/test.jpg">
    144144ftp://255.255.255.255/test.jpg - willSendRequest <NSURLRequest URL ftp://255.255.255.255/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
    145145ftp://255.255.255.255/test.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1, failing URL "ftp://255.255.255.255/test.jpg">
    146 ftp://255.255.255.255:21/test.jpg - willSendRequest <NSURLRequest URL ftp://255.255.255.255:21/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
    147 ftp://255.255.255.255:21/test.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1, failing URL "ftp://255.255.255.255:21/test.jpg">
     146ftp://255.255.255.255/test.jpg - willSendRequest <NSURLRequest URL ftp://255.255.255.255/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
     147ftp://255.255.255.255/test.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1, failing URL "ftp://255.255.255.255/test.jpg">
    148148ftp://255.255.255.255:22/test.jpg - willSendRequest <NSURLRequest URL ftp://255.255.255.255:22/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
    149149ftp://255.255.255.255:22/test.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1, failing URL "ftp://255.255.255.255:22/test.jpg">
  • trunk/Source/WebCore/ChangeLog

    r78377 r78383  
     12011-02-11  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        KURL should remove default port numbers when cannonicalizing urls (to match every other browser)
     6        https://bugs.webkit.org/show_bug.cgi?id=54090
     7
     8        * platform/KURL.cpp:
     9        (WebCore::isDefaultPortForScheme):
     10        (WebCore::KURL::parse):
     11
    1122011-02-11  Mike Reed  <reed@google.com>
    213
  • trunk/Source/WebCore/platform/KURL.cpp

    r78044 r78383  
    11011101}
    11021102
     1103static inline bool equal(const char* a, size_t lenA, const char* b, size_t lenB)
     1104{
     1105    if (lenA != lenB)
     1106        return false;
     1107    return !strncmp(a, b, lenA);
     1108}
     1109
     1110// List of default schemes is taken from google-url:
     1111// http://code.google.com/p/google-url/source/browse/trunk/src/url_canon_stdurl.cc#120
     1112static inline bool isDefaultPortForScheme(const char* port, size_t portLength, const char* scheme, size_t schemeLength)
     1113{
     1114    // This switch is theoretically a performance optimization.  It came over when
     1115    // the code was moved from google-url, but may be removed later.
     1116    switch (schemeLength) {
     1117    case 2:
     1118        return equal("ws", 2, scheme, schemeLength) && equal("80", 2, port, portLength);
     1119    case 3:
     1120        if (equal("ftp", 3, scheme, schemeLength))
     1121            return equal("21", 2, port, portLength);
     1122        if (equal("wss", 3, scheme, schemeLength))
     1123            return equal("443", 3, port, portLength);
     1124        break;
     1125    case 4:
     1126        return equal("http", 4, scheme, schemeLength) && equal("80", 2, port, portLength);
     1127    case 5:
     1128        return equal("https", 5, scheme, schemeLength) && equal("443", 3, port, portLength);
     1129    case 6:
     1130        return equal("gopher", 6, scheme, schemeLength) && equal("70", 2, port, portLength);
     1131    }
     1132    return false;
     1133}
     1134
    11031135void KURL::parse(const char* url, const String* originalString)
    11041136{
     
    13361368        m_hostEnd = p - buffer.data();
    13371369
    1338         // copy in the port
     1370        // Copy in the port if the URL has one (and it's not default).
    13391371        if (hostEnd != portStart) {
    1340             *p++ = ':';
    1341             strPtr = url + portStart;
    1342             const char *portEndPtr = url + portEnd;
    1343             while (strPtr < portEndPtr)
    1344                 *p++ = *strPtr++;
     1372            const char* portStr = url + portStart;
     1373            size_t portLength = portEnd - portStart;
     1374            if (portLength && !isDefaultPortForScheme(portStr, portLength, buffer.data(), m_schemeEnd)) {
     1375                *p++ = ':';
     1376                const char* portEndPtr = url + portEnd;
     1377                while (portStr < portEndPtr)
     1378                    *p++ = *portStr++;
     1379            }
    13451380        }
    13461381        m_portEnd = p - buffer.data();
Note: See TracChangeset for help on using the changeset viewer.