Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2531163004: Remove attributes that contain javascript from MHTML (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
9 * (C) 2007 Eric Seidel (eric@webkit.org) 9 * (C) 2007 Eric Seidel (eric@webkit.org)
10 * 10 *
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 } else { 1423 } else {
1424 const SpaceSplitString& oldClasses = elementData()->classNames(); 1424 const SpaceSplitString& oldClasses = elementData()->classNames();
1425 if (featureSet.checkSelectorsForClassChange(oldClasses)) 1425 if (featureSet.checkSelectorsForClassChange(oldClasses))
1426 return true; 1426 return true;
1427 } 1427 }
1428 } 1428 }
1429 1429
1430 return featureSet.hasSelectorForAttribute(name.localName()); 1430 return featureSet.hasSelectorForAttribute(name.localName());
1431 } 1431 }
1432 1432
1433 // Returns true is the given attribute is an event handler.
1434 // We consider an event handler any attribute that begins with "on".
1435 // It is a simple solution that has the advantage of not requiring any
1436 // code or configuration change if a new event handler is defined.
1437
1438 static inline bool isEventHandlerAttribute(const Attribute& attribute) {
1439 return attribute.name().namespaceURI().isNull() &&
1440 attribute.name().localName().startsWith("on");
1441 }
1442
1443 bool Element::attributeValueIsJavaScriptURL(const Attribute& attribute) { 1433 bool Element::attributeValueIsJavaScriptURL(const Attribute& attribute) {
1444 return protocolIsJavaScript( 1434 return protocolIsJavaScript(
1445 stripLeadingAndTrailingHTMLSpaces(attribute.value())); 1435 stripLeadingAndTrailingHTMLSpaces(attribute.value()));
1446 } 1436 }
1447 1437
1448 bool Element::isJavaScriptURLAttribute(const Attribute& attribute) const { 1438 bool Element::isJavaScriptURLAttribute(const Attribute& attribute) const {
1449 return isURLAttribute(attribute) && attributeValueIsJavaScriptURL(attribute); 1439 return isURLAttribute(attribute) && attributeValueIsJavaScriptURL(attribute);
1450 } 1440 }
1451 1441
1452 void Element::stripScriptingAttributes( 1442 void Element::stripScriptingAttributes(
(...skipping 2629 matching lines...) Expand 10 before | Expand all | Expand 10 after
4082 } 4072 }
4083 4073
4084 DEFINE_TRACE_WRAPPERS(Element) { 4074 DEFINE_TRACE_WRAPPERS(Element) {
4085 if (hasRareData()) { 4075 if (hasRareData()) {
4086 visitor->traceWrappers(elementRareData()); 4076 visitor->traceWrappers(elementRareData());
4087 } 4077 }
4088 ContainerNode::traceWrappers(visitor); 4078 ContainerNode::traceWrappers(visitor);
4089 } 4079 }
4090 4080
4091 } // namespace blink 4081 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698