Changeset 52812 in webkit


Ignore:
Timestamp:
Jan 5, 2010 11:06:29 AM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-01-05 Nate Chapin <Nate Chapin>

Reviewed by Adam Barth.

Move allowSetting{Frame}SrcToJavascriptUrl from V8Custom to BindingSecurity and
remove the v8-specific pieces.

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

  • bindings/BindingSecurity.h: (WebCore::::allowSettingFrameSrcToJavascriptUrl): Moved from V8CustomBinding.cpp. (WebCore::::allowSettingSrcToJavascriptURL): Moved from V8CustomBinding.cpp.
  • bindings/v8/custom/V8AttrCustom.cpp: (WebCore::V8Attr::valueAccessorSetter):
  • bindings/v8/custom/V8CustomBinding.cpp:
  • bindings/v8/custom/V8CustomBinding.h:
  • bindings/v8/custom/V8ElementCustom.cpp: (WebCore::V8Element::setAttributeCallback): (WebCore::V8Element::setAttributeNodeCallback): (WebCore::V8Element::setAttributeNSCallback): (WebCore::V8Element::setAttributeNodeNSCallback):
  • bindings/v8/custom/V8HTMLFrameElementCustom.cpp: (WebCore::V8HTMLFrameElement::srcAccessorSetter): (WebCore::V8HTMLFrameElement::locationAccessorSetter):
  • bindings/v8/custom/V8HTMLIFrameElementCustom.cpp: (WebCore::V8HTMLIFrameElement::srcAccessorSetter):
Location:
trunk/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52811 r52812  
     12010-01-05  Nate Chapin  <japhet@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Move allowSetting{Frame}SrcToJavascriptUrl from V8Custom to BindingSecurity and
     6        remove the v8-specific pieces.
     7
     8        https://bugs.webkit.org/show_bug.cgi?id=33182
     9
     10        * bindings/BindingSecurity.h:
     11        (WebCore::::allowSettingFrameSrcToJavascriptUrl): Moved from V8CustomBinding.cpp.
     12        (WebCore::::allowSettingSrcToJavascriptURL): Moved from V8CustomBinding.cpp.
     13        * bindings/v8/custom/V8AttrCustom.cpp:
     14        (WebCore::V8Attr::valueAccessorSetter):
     15        * bindings/v8/custom/V8CustomBinding.cpp:
     16        * bindings/v8/custom/V8CustomBinding.h:
     17        * bindings/v8/custom/V8ElementCustom.cpp:
     18        (WebCore::V8Element::setAttributeCallback):
     19        (WebCore::V8Element::setAttributeNodeCallback):
     20        (WebCore::V8Element::setAttributeNSCallback):
     21        (WebCore::V8Element::setAttributeNodeNSCallback):
     22        * bindings/v8/custom/V8HTMLFrameElementCustom.cpp:
     23        (WebCore::V8HTMLFrameElement::srcAccessorSetter):
     24        (WebCore::V8HTMLFrameElement::locationAccessorSetter):
     25        * bindings/v8/custom/V8HTMLIFrameElementCustom.cpp:
     26        (WebCore::V8HTMLIFrameElement::srcAccessorSetter):
     27
    1282010-01-05  Adam Barth  <abarth@webkit.org>
    229
  • trunk/WebCore/bindings/generic/BindingSecurity.h

    r52810 r52812  
    3333
    3434#include "BindingSecurityBase.h"
     35#include "CSSHelper.h"
     36#include "Element.h"
    3537#include "GenericBinding.h"
     38#include "HTMLFrameElementBase.h"
    3639
    3740namespace WebCore {
     
    5154    // current security context.
    5255    static bool checkNodeSecurity(State<Binding>*, Node* target);
     56
     57    static bool allowSettingFrameSrcToJavascriptUrl(State<Binding>*, HTMLFrameElementBase*, String value);
     58    static bool allowSettingSrcToJavascriptURL(State<Binding>*, Element*, String name, String value);
    5359
    5460private:
     
    103109}
    104110
     111template <class Binding>
     112bool BindingSecurity<Binding>::allowSettingFrameSrcToJavascriptUrl(State<Binding>* state, HTMLFrameElementBase* frame, String value)
     113{
     114    if (protocolIsJavaScript(deprecatedParseURL(value))) {
     115        Node* contentDoc = frame->contentDocument();
     116        if (contentDoc && !checkNodeSecurity(state, contentDoc))
     117            return false;
     118    }
     119    return true;
     120}
     121
     122template <class Binding>
     123bool BindingSecurity<Binding>::allowSettingSrcToJavascriptURL(State<Binding>* state, Element* element, String name, String value)
     124{
     125    if ((element->hasTagName(HTMLNames::iframeTag) || element->hasTagName(HTMLNames::frameTag)) && equalIgnoringCase(name, "src"))
     126        return allowSettingFrameSrcToJavascriptUrl(state, static_cast<HTMLFrameElementBase*>(element), value);
     127    return true;
     128}
     129
    105130}
    106131
  • trunk/WebCore/bindings/v8/custom/V8AttrCustom.cpp

    r52672 r52812  
    3636#include "ExceptionCode.h"
    3737#include "V8Binding.h"
     38#include "V8BindingState.h"
    3839#include "V8CustomBinding.h"
    3940#include "V8Proxy.h"
     
    4748    Element* ownerElement = imp->ownerElement();
    4849
    49     if (ownerElement && !allowSettingSrcToJavascriptURL(ownerElement, imp->name(), attrValue))
     50    if (ownerElement && !V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), ownerElement, imp->name(), attrValue))
    5051        return;
    5152
  • trunk/WebCore/bindings/v8/custom/V8CustomBinding.cpp

    r52672 r52812  
    4949
    5050namespace WebCore {
    51 
    52 bool allowSettingFrameSrcToJavascriptUrl(HTMLFrameElementBase* frame, String value)
    53 {
    54     if (protocolIs(deprecatedParseURL(value), "javascript")) {
    55         Node* contentDoc = frame->contentDocument();
    56         if (contentDoc && !V8BindingSecurity::checkNodeSecurity(V8BindingState::Only(), contentDoc))
    57             return false;
    58     }
    59     return true;
    60 }
    61 
    62 bool allowSettingSrcToJavascriptURL(Element* element, String name, String value)
    63 {
    64     if ((element->hasTagName(HTMLNames::iframeTag) || element->hasTagName(HTMLNames::frameTag)) && equalIgnoringCase(name, "src"))
    65         return allowSettingFrameSrcToJavascriptUrl(static_cast<HTMLFrameElementBase*>(element), value);
    66     return true;
    67 }
    6851
    6952// --------------- Security Checks -------------------------
  • trunk/WebCore/bindings/v8/custom/V8CustomBinding.h

    r52747 r52812  
    7979    class V8Proxy;
    8080
    81     bool allowSettingFrameSrcToJavascriptUrl(HTMLFrameElementBase*, String value);
    82     bool allowSettingSrcToJavascriptURL(Element*, String name, String value);
    83 
    8481    class V8Custom {
    8582    public:
  • trunk/WebCore/bindings/v8/custom/V8ElementCustom.cpp

    r52459 r52812  
    4343#include "V8Attr.h"
    4444#include "V8Binding.h"
     45#include "V8BindingState.h"
    4546#include "V8CustomBinding.h"
    4647#include "V8Proxy.h"
     
    5758    String value = toWebCoreString(args[1]);
    5859
    59     if (!allowSettingSrcToJavascriptURL(element, name, value))
     60    if (!V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), element, name, value))
    6061        return v8::Undefined();
    6162
     
    7778    Element* element = V8DOMWrapper::convertDOMWrapperToNode<Element>(args.Holder());
    7879
    79     if (!allowSettingSrcToJavascriptURL(element, newAttr->name(), newAttr->value()))
     80    if (!V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), element, newAttr->name(), newAttr->value()))
    8081        return v8::Undefined();
    8182
     
    9697    String value = toWebCoreString(args[2]);
    9798
    98     if (!allowSettingSrcToJavascriptURL(element, qualifiedName, value))
     99    if (!V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), element, qualifiedName, value))
    99100        return v8::Undefined();
    100101
     
    116117    Element* element = V8DOMWrapper::convertDOMWrapperToNode<Element>(args.Holder());
    117118
    118     if (!allowSettingSrcToJavascriptURL(element, newAttr->name(), newAttr->value()))
     119    if (!V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), element, newAttr->name(), newAttr->value()))
    119120        return v8::Undefined();
    120121
  • trunk/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp

    r52672 r52812  
    3535#include "HTMLNames.h"
    3636#include "V8Binding.h"
     37#include "V8BindingState.h"
    3738#include "V8CustomBinding.h"
    3839#include "V8Proxy.h"
     
    4748    String srcValue = toWebCoreStringWithNullCheck(value);
    4849
    49     if (!allowSettingFrameSrcToJavascriptUrl(frame, srcValue))
     50    if (!V8BindingSecurity::allowSettingFrameSrcToJavascriptUrl(V8BindingState::Only(), frame, srcValue))
    5051        return;
    5152
     
    5859    String locationValue = toWebCoreStringWithNullCheck(value);
    5960
    60     if (!allowSettingFrameSrcToJavascriptUrl(frame, locationValue))
     61    if (!V8BindingSecurity::allowSettingFrameSrcToJavascriptUrl(V8BindingState::Only(), frame, locationValue))
    6162        return;
    6263
  • trunk/WebCore/bindings/v8/custom/V8HTMLIFrameElementCustom.cpp

    r52672 r52812  
    3535#include "HTMLNames.h"
    3636#include "V8Binding.h"
     37#include "V8BindingState.h"
    3738#include "V8CustomBinding.h"
    3839#include "V8Proxy.h"
     
    4748    String v = toWebCoreStringWithNullCheck(value);
    4849
    49     if (!allowSettingFrameSrcToJavascriptUrl(iframe, v))
     50    if (!V8BindingSecurity::allowSettingFrameSrcToJavascriptUrl(V8BindingState::Only(), iframe, v))
    5051        return;
    5152
Note: See TracChangeset for help on using the changeset viewer.