Changeset 58219 in webkit


Ignore:
Timestamp:
Apr 24, 2010 9:40:49 AM (14 years ago)
Author:
jchaffraix@webkit.org
Message:

protocolHostAndPortEquals host check makes a wrong assumption
https://bugs.webkit.org/show_bug.cgi?id=37777

Reviewed by Alexey Proskuryakov.

WebCore:

The host check assumed that both host started at the same position. This is true
if both URL are the same but sometimes one has credential and the other does not.
In this case, the method would compare invalid positions.

Test: http/tests/appcache/credential-url.html

  • platform/KURL.cpp:

(WebCore::protocolHostAndPortAreEqual):

  • platform/KURLGoogle.cpp:

(WebCore::protocolHostAndPortAreEqual):
Fix the host check to take both URL's credential into account.

LayoutTests:

Add a check that the URL with credential matches the current URL.

  • http/tests/appcache/credential-url-expected.txt: Added.
  • http/tests/appcache/credential-url.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r58218 r58219  
     12010-04-24  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        protocolHostAndPortEquals host check makes a wrong assumption
     6        https://bugs.webkit.org/show_bug.cgi?id=37777
     7
     8        Add a check that the URL with credential matches the current URL.
     9
     10        * http/tests/appcache/credential-url-expected.txt: Added.
     11        * http/tests/appcache/credential-url.html: Added.
     12
    1132010-04-20  Robert Hogan  <robert@webkit.org>
    214
  • trunk/WebCore/ChangeLog

    r58214 r58219  
     12010-04-24  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        protocolHostAndPortEquals host check makes a wrong assumption
     6        https://bugs.webkit.org/show_bug.cgi?id=37777
     7
     8        The host check assumed that both host started at the same position. This is true
     9        if both URL are the same but sometimes one has credential and the other does not.
     10        In this case, the method would compare invalid positions.
     11
     12        Test: http/tests/appcache/credential-url.html
     13
     14        * platform/KURL.cpp:
     15        (WebCore::protocolHostAndPortAreEqual):
     16        * platform/KURLGoogle.cpp:
     17        (WebCore::protocolHostAndPortAreEqual):
     18        Fix the host check to take both URL's credential into account.
     19
    1202010-04-24  Nikolas Zimmermann  <nzimmermann@rim.com>
    221
  • trunk/WebCore/platform/KURL.cpp

    r56879 r58219  
    13541354    if (a.m_schemeEnd != b.m_schemeEnd)
    13551355        return false;
     1356
    13561357    int hostStartA = a.hostStart();
     1358    int hostLengthA = a.hostEnd() - hostStartA;
    13571359    int hostStartB = b.hostStart();
    1358     if (a.m_hostEnd - hostStartA != b.m_hostEnd - hostStartB)
     1360    int hostLengthB = b.hostEnd() - b.hostStart();
     1361    if (hostLengthA != hostLengthB)
    13591362        return false;
    13601363
     
    13631366        if (a.string()[i] != b.string()[i])
    13641367            return false;
    1365    
     1368
    13661369    // And the host
    1367     for (int i = hostStartA; i < a.m_hostEnd; ++i)
    1368         if (a.string()[i] != b.string()[i])
     1370    for (int i = 0; i < hostLengthA; ++i)
     1371        if (a.string()[hostStartA + i] != b.string()[hostStartB + i])
    13691372            return false;
    1370    
     1373
    13711374    if (a.port() != b.port())
    13721375        return false;
     
    13741377    return true;
    13751378}
    1376    
    13771379
    13781380String encodeWithURLEscapeSequences(const String& notEncodedString)
  • trunk/WebCore/platform/KURLGoogle.cpp

    r57101 r58219  
    11451145
    11461146    int hostStartA = a.hostStart();
     1147    int hostLengthA = a.hostEnd() - hostStartA;
    11471148    int hostStartB = b.hostStart();
    1148     if (a.hostEnd() - hostStartA != b.hostEnd() - hostStartB)
     1149    int hostLengthB = b.hostEnd() - b.hostStart();
     1150    if (hostLengthA != hostLengthB)
    11491151        return false;
    11501152
     
    11551157   
    11561158    // And the host
    1157     for (int i = hostStartA; i < static_cast<int>(a.hostEnd()); ++i)
    1158         if (a.string()[i] != b.string()[i])
     1159    for (int i = 0; i < hostLengthA; ++i)
     1160        if (a.string()[hostStartA + i] != b.string()[hostStartB + i])
    11591161            return false;
    11601162   
Note: See TracChangeset for help on using the changeset viewer.