Changeset 56879 in webkit


Ignore:
Timestamp:
Mar 31, 2010 5:13:37 PM (14 years ago)
Author:
mrowe@apple.com
Message:

<http://webkit.org/b/36878> REGRESSION: Trailing colon on hostnames (with no port specified) causes "Not allowed to use restricted network port"

Reviewed by Darin Adler.

WebCore:

  • platform/KURL.cpp:

(WebCore::KURL::port): Explicitly handle the case of a colon being present in the URL after the host name but with
no port number before the path. This is handled in the same manner as the colon and port being omitted completely.

LayoutTests:

Add explicit tests for handling of allowed ports. We currently only test the ports that map to port 80: 0, 80, and "".

  • platform/mac/security/block-test-expected.txt:
  • security/block-test.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r56873 r56879  
     12010-03-31  Mark Rowe  <mrowe@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <http://webkit.org/b/36878> REGRESSION: Trailing colon on hostnames (with no port specified) causes "Not allowed to use restricted network port"
     6
     7        Add explicit tests for handling of allowed ports.  We currently only test the ports that map to port 80: 0, 80, and "".
     8
     9        * platform/mac/security/block-test-expected.txt:
     10        * security/block-test.html:
     11
    1122010-03-31  Andrew Scherkus  <scherkus@chromium.org>
    213
  • trunk/LayoutTests/platform/mac/security/block-test-expected.txt

    r56492 r56879  
    136136http://255.255.255.255:4294967296/test.jpg - willSendRequest <NSURLRequest URL http://255.255.255.255:4294967296/test.jpg, main document URL block-test.html, http method GET> redirectResponse (null)
    137137http://255.255.255.255:4294967296/test.jpg - didFailLoadingWithError: <NSError domain WebKitErrorDomain, code 103, failing URL "http://255.255.255.255:4294967296/test.jpg">
     138http://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)
     139http://255.255.255.255:0/test.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://255.255.255.255:0/test.jpg">
     140http://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)
     141http://255.255.255.255:80/test.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://255.255.255.255:80/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">
    138144ftp://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)
    139145ftp://255.255.255.255/test.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1, failing URL "ftp://255.255.255.255/test.jpg">
  • trunk/LayoutTests/security/block-test.html

    r56492 r56879  
    22<script>
    33    // Note that port "1" is tested by the initial load.
    4     var blockedPorts = new Array(7, 9, 11, 13, 15, 17, 19, 20,
     4    var blockedPorts = [7, 9, 11, 13, 15, 17, 19, 20,
    55      21, 22, 23, 25, 37, 42, 43, 53, 77, 79, 87, 95, 101, 102,
    66      103, 104, 109, 110, 111, 113, 115, 117, 119, 123, 135, 139,
     
    1010
    1111      // Port numbers that we consider to be invalid due to being out of range.
    12       Math.pow(2, 16) - 1, Math.pow(2, 16), Math.pow(2, 32) - 1, Math.pow(2, 32),
     12      Math.pow(2, 16) - 1, Math.pow(2, 16), Math.pow(2, 32) - 1, Math.pow(2, 32)];
    1313
    14       // A port number of 0 indicates to nextTest that it should test the FTP exemptions.
    15       0);
    16    
     14    var allowedPorts = [0, 80, ""];
     15
    1716    var baseURL = "255.255.255.255";
    1817    var currentPort = 0;
    19    
     18
    2019    if (window.layoutTestController) {
    2120        layoutTestController.waitUntilDone();
    2221        layoutTestController.dumpResourceLoadCallbacks();
    2322    }
    24        
    25     function nextTest() {
    26         if (!blockedPorts[currentPort]) {
    27             ftpTest();
     23
     24    function nextBlockedPortTest() {
     25        if (!(currentPort in blockedPorts)) {
     26            currentPort = 0;
     27            nextAllowedPortTest();
    2828            return;
    2929        }
     
    3232        testIMG.src = newURL;
    3333    }
    34    
     34
     35    function nextAllowedPortTest() {
     36        if (!(currentPort in allowedPorts)) {
     37            ftpTest();
     38            return;
     39        }
     40        var newURL = "http://" + baseURL + ":" + allowedPorts[currentPort] + "/test.jpg";
     41        currentPort++;
     42        testIMG.setAttribute("onError", "nextAllowedPortTest();");
     43        testIMG.src = newURL;
     44    }
     45
    3546    function ftpTest() {
    3647        testIMG.setAttribute("onError", "ftp21Test();");
     
    3849        testIMG.src = newURL;
    3950    }
    40    
     51
    4152    function ftp21Test() {
    4253        testIMG.setAttribute("onError", "ftp22Test();");
     
    4455        testIMG.src = newURL;
    4556    }
    46    
     57
    4758    function ftp22Test() {
    4859        testIMG.setAttribute("onError", "finishTesting();");
     
    5061        testIMG.src = newURL;
    5162    }
    52    
     63
    5364    function finishTesting() {
    5465        if (window.layoutTestController) {
     
    6374nature of this test, the results can only be processed automatically via DumpRenderTree
    6475</p>
    65 <img id="testIMG" src="http://255.255.255.255:1/test.jpg" onError="nextTest();"></img>
     76<img id="testIMG" src="http://255.255.255.255:1/test.jpg" onError="nextBlockedPortTest();"></img>
    6677</body>
    6778</html>
  • trunk/WebCore/ChangeLog

    r56878 r56879  
     12010-03-31  Mark Rowe  <mrowe@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <http://webkit.org/b/36878> REGRESSION: Trailing colon on hostnames (with no port specified) causes "Not allowed to use restricted network port"
     6
     7        * platform/KURL.cpp:
     8        (WebCore::KURL::port): Explicitly handle the case of a colon being present in the URL after the host name but with
     9        no port number before the path.  This is handled in the same manner as the colon and port being omitted completely.
     10
    1112010-03-31  Gavin Barraclough  <barraclough@apple.com>
    212
  • trunk/WebCore/platform/KURL.cpp

    r56825 r56879  
    577577unsigned short KURL::port() const
    578578{
    579     if (m_hostEnd == m_portEnd)
     579    // We return a port of 0 if there is no port specified. This can happen in two situations:
     580    // 1) The URL contains no colon after the host name and before the path component of the URL.
     581    // 2) The URL contains a colon but there's no port number before the path component of the URL begins.
     582    if (m_hostEnd == m_portEnd || m_hostEnd == m_portEnd - 1)
    580583        return 0;
    581584
Note: See TracChangeset for help on using the changeset viewer.