Changeset 54997 in webkit


Ignore:
Timestamp:
Feb 18, 2010 6:06:14 PM (14 years ago)
Author:
brettw@chromium.org
Message:

2010-02-12 Brett Wilson <brettw@chromium.org>

Reviewed by Adam Barth.

Update the Google-URL version of KURL and the V8 bindings to the new
behavior of KURL.IsStandard.

https://bugs.webkit.org/show_bug.cgi?id=34859

This is covered by fast/dom/Window/invalid-protocol.html

  • bindings/v8/custom/V8LocationCustom.cpp: (WebCore::V8Location::protocolAccessorSetter):
  • platform/KURLGoogle.cpp: (WebCore::KURL::setProtocol): (WebCore::KURL::isHierarchical):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r54995 r54997  
     12010-02-12  Brett Wilson  <brettw@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Update the Google-URL version of KURL and the V8 bindings to the new
     6        behavior of KURL.IsStandard.
     7
     8        https://bugs.webkit.org/show_bug.cgi?id=34859
     9
     10        This is covered by fast/dom/Window/invalid-protocol.html
     11
     12        * bindings/v8/custom/V8LocationCustom.cpp:
     13        (WebCore::V8Location::protocolAccessorSetter):
     14        * platform/KURLGoogle.cpp:
     15        (WebCore::KURL::setProtocol):
     16        (WebCore::KURL::isHierarchical):
     17
    1182010-02-18  Simon Fraser  <simon.fraser@apple.com>
    219
  • trunk/WebCore/bindings/v8/custom/V8LocationCustom.cpp

    r54629 r54997  
    186186
    187187    KURL url = frame->loader()->url();
    188     url.setProtocol(protocol);
     188    if (!url.setProtocol(protocol)) {
     189        throwError("Can't set protocol", V8Proxy::SyntaxError);
     190        return;
     191    }
    189192
    190193    navigateIfAllowed(frame, url, false, false);
  • trunk/WebCore/platform/KURLGoogle.cpp

    r53712 r54997  
    573573bool KURL::setProtocol(const String& protocol)
    574574{
     575    // Firefox and IE remove everything after the first ':'.
     576    int separatorPosition = protocol.find(':');
     577    String newProtocol = protocol.substring(0, separatorPosition);
     578
     579    // If KURL is given an invalid scheme, it returns failure without modifying
     580    // the URL at all. This is in contrast to most other setters which modify
     581    // the URL and set "m_isValid."
     582    url_canon::RawCanonOutputT<char> canonProtocol;
     583    url_parse::Component protocolComponent;
     584    if (!url_canon::CanonicalizeScheme(newProtocol.characters(),
     585                                       url_parse::Component(0, newProtocol.length()),
     586                                       &canonProtocol, &protocolComponent)
     587        || !protocolComponent.is_nonempty())
     588        return false;
     589
    575590    KURLGooglePrivate::Replacements replacements;
    576     replacements.SetScheme(CharactersOrEmpty(protocol),
    577                            url_parse::Component(0, protocol.length()));
     591    replacements.SetScheme(CharactersOrEmpty(newProtocol),
     592                           url_parse::Component(0, newProtocol.length()));
    578593    m_url.replaceComponents(replacements);
     594
     595    // isValid could be false but we still return true here. This is because
     596    // WebCore or JS scripts can build up a URL by setting individual
     597    // components, and a JS exception is based on the return value of this
     598    // function. We want to throw the exception and stop the script only when
     599    // its trying to set a bad protocol, and not when it maybe just hasn't
     600    // finished building up its final scheme.
    579601    return true;
    580602}
     
    10161038    return url_util::IsStandard(
    10171039        &m_url.utf8String().data()[m_url.m_parsed.scheme.begin],
    1018         m_url.utf8String().length(),
    10191040        m_url.m_parsed.scheme);
    10201041}
Note: See TracChangeset for help on using the changeset viewer.