Changeset 48063 in webkit


Ignore:
Timestamp:
Sep 4, 2009 10:53:00 AM (15 years ago)
Author:
yael.aharon@nokia.com
Message:

WebCore: hostname and host are mixed up when manipulating anchor elements.
https://bugs.webkit.org/show_bug.cgi?id=28954

Patch by Yael Aharon <yael.aharon@nokia.com> on 2009-09-04
Reviewed by Darin Adler.

Swapped the implementation of host and hostname, and made sure not to return
the port number if it is default for the given protocol.
FireFox also avoids returning the protocol number if it is default.

Test: fast/dom/Element/hostname-host.html

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r48059 r48063  
     12009-09-04  Yael Aharon  <yael.aharon@nokia.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        hostname and host are mixed up when manipulating anchor elements.
     6        https://bugs.webkit.org/show_bug.cgi?id=28954
     7
     8        * fast/dom/Element/hostname-host-expected.txt: Added.
     9        * fast/dom/Element/hostname-host.html: Added.
     10
    1112009-09-04  Dimitri Glazkov  <dglazkov@chromium.org>
    212
  • trunk/WebCore/ChangeLog

    r48062 r48063  
     12009-09-04  Yael Aharon  <yael.aharon@nokia.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        hostname and host are mixed up when manipulating anchor elements.
     6        https://bugs.webkit.org/show_bug.cgi?id=28954
     7
     8        Swapped the implementation of host and hostname, and made sure not to return
     9        the port number if it is default for the given protocol.
     10        FireFox also avoids returning the protocol number if it is default.
     11
     12        Test: fast/dom/Element/hostname-host.html
     13
     14        * html/HTMLAnchorElement.cpp:
     15        (WebCore::HTMLAnchorElement::host):
     16        (WebCore::HTMLAnchorElement::hostname):
     17        * page/SecurityOrigin.cpp:
     18        (WebCore::SecurityOrigin::isDefaultPortForProtocol):
     19        * page/SecurityOrigin.h:
     20
    1212009-09-04  Anders Carlsson  <andersca@apple.com>
    222
  • trunk/WebCore/html/HTMLAnchorElement.cpp

    r47688 r48063  
    353353String HTMLAnchorElement::host() const
    354354{
    355     return href().host();
    356 }
    357 
    358 String HTMLAnchorElement::hostname() const
    359 {
    360355    const KURL& url = href();
    361356    if (url.port() == 0)
    362357        return url.host();
     358    if (SecurityOrigin::isDefaultPortForProtocol(url.port(), url.protocol()))
     359        return url.host();
    363360    return url.host() + ":" + String::number(url.port());
     361}
     362
     363String HTMLAnchorElement::hostname() const
     364{
     365    return href().host();
    364366}
    365367
  • trunk/WebCore/page/SecurityOrigin.cpp

    r47548 r48063  
    7474}
    7575
    76 static bool isDefaultPortForProtocol(unsigned short port, const String& protocol)
     76bool SecurityOrigin::isDefaultPortForProtocol(unsigned short port, const String& protocol)
    7777{
    7878    if (protocol.isEmpty())
  • trunk/WebCore/page/SecurityOrigin.h

    r47548 r48063  
    145145        static void resetOriginAccessWhiteLists();
    146146
     147        static bool isDefaultPortForProtocol(unsigned short port, const String& protocol);
     148
    147149    private:
    148150        explicit SecurityOrigin(const KURL&);
Note: See TracChangeset for help on using the changeset viewer.