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

Unified Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2531163004: Remove attributes that contain javascript from MHTML (Closed)
Patch Set: Address final feedback 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Element.cpp
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index 047e339cba3e817a5c7eb056291cb3d2776f7584..50683b81cb2b57dbf2573edb154039c7f6b37a84 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -1430,7 +1430,7 @@ bool Element::shouldInvalidateDistributionWhenAttributeChanged(
return featureSet.hasSelectorForAttribute(name.localName());
}
-// Returns true is the given attribute is an event handler.
+// Returns true if the given attribute is an event handler.
// We consider an event handler any attribute that begins with "on".
// It is a simple solution that has the advantage of not requiring any
// code or configuration change if a new event handler is defined.
@@ -1449,14 +1449,18 @@ bool Element::isJavaScriptURLAttribute(const Attribute& attribute) const {
return isURLAttribute(attribute) && attributeValueIsJavaScriptURL(attribute);
}
+bool Element::isScriptingAttribute(const Attribute& attribute) const {
+ return isEventHandlerAttribute(attribute) ||
+ isJavaScriptURLAttribute(attribute) ||
+ isHTMLContentAttribute(attribute) ||
+ isSVGAnimationAttributeSettingJavaScriptURL(attribute);
+}
+
void Element::stripScriptingAttributes(
Vector<Attribute>& attributeVector) const {
size_t destination = 0;
for (size_t source = 0; source < attributeVector.size(); ++source) {
- if (isEventHandlerAttribute(attributeVector[source]) ||
- isJavaScriptURLAttribute(attributeVector[source]) ||
- isHTMLContentAttribute(attributeVector[source]) ||
- isSVGAnimationAttributeSettingJavaScriptURL(attributeVector[source]))
+ if (isScriptingAttribute(attributeVector[source]))
continue;
if (source != destination)
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/editing/serializers/MarkupAccumulator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698