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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameSerializer.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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 STACK_ALLOCATED(); 92 STACK_ALLOCATED();
93 93
94 public: 94 public:
95 SerializerMarkupAccumulator(FrameSerializer::Delegate&, 95 SerializerMarkupAccumulator(FrameSerializer::Delegate&,
96 const Document&, 96 const Document&,
97 HeapVector<Member<Node>>&); 97 HeapVector<Member<Node>>&);
98 ~SerializerMarkupAccumulator() override; 98 ~SerializerMarkupAccumulator() override;
99 99
100 protected: 100 protected:
101 void appendText(StringBuilder& out, Text&) override; 101 void appendText(StringBuilder& out, Text&) override;
102 bool shouldIgnoreAttribute(const Attribute&) override; 102 bool shouldIgnoreAttribute(const Element&, const Attribute&) override;
103 void appendElement(StringBuilder& out, Element&, Namespaces*) override; 103 void appendElement(StringBuilder& out, Element&, Namespaces*) override;
104 void appendAttribute(StringBuilder& out, 104 void appendAttribute(StringBuilder& out,
105 const Element&, 105 const Element&,
106 const Attribute&, 106 const Attribute&,
107 Namespaces*) override; 107 Namespaces*) override;
108 void appendStartTag(Node&, Namespaces* = nullptr) override; 108 void appendStartTag(Node&, Namespaces* = nullptr) override;
109 void appendEndTag(const Element&) override; 109 void appendEndTag(const Element&) override;
110 110
111 private: 111 private:
112 void appendAttributeValue(StringBuilder& out, const String& attributeValue); 112 void appendAttributeValue(StringBuilder& out, const String& attributeValue);
(...skipping 27 matching lines...) Expand all
140 SerializerMarkupAccumulator::~SerializerMarkupAccumulator() {} 140 SerializerMarkupAccumulator::~SerializerMarkupAccumulator() {}
141 141
142 void SerializerMarkupAccumulator::appendText(StringBuilder& result, 142 void SerializerMarkupAccumulator::appendText(StringBuilder& result,
143 Text& text) { 143 Text& text) {
144 Element* parent = text.parentElement(); 144 Element* parent = text.parentElement();
145 if (parent && !shouldIgnoreElement(*parent)) 145 if (parent && !shouldIgnoreElement(*parent))
146 MarkupAccumulator::appendText(result, text); 146 MarkupAccumulator::appendText(result, text);
147 } 147 }
148 148
149 bool SerializerMarkupAccumulator::shouldIgnoreAttribute( 149 bool SerializerMarkupAccumulator::shouldIgnoreAttribute(
150 const Element& element,
150 const Attribute& attribute) { 151 const Attribute& attribute) {
151 return m_delegate.shouldIgnoreAttribute(attribute); 152 return m_delegate.shouldIgnoreAttribute(element, attribute);
152 } 153 }
153 154
154 void SerializerMarkupAccumulator::appendElement(StringBuilder& result, 155 void SerializerMarkupAccumulator::appendElement(StringBuilder& result,
155 Element& element, 156 Element& element,
156 Namespaces* namespaces) { 157 Namespaces* namespaces) {
157 if (!shouldIgnoreElement(element)) 158 if (!shouldIgnoreElement(element))
158 MarkupAccumulator::appendElement(result, element, namespaces); 159 MarkupAccumulator::appendElement(result, element, namespaces);
159 160
160 // TODO(tiger): Refactor MarkupAccumulator so it is easier to append an 161 // TODO(tiger): Refactor MarkupAccumulator so it is easier to append an
161 // element like this, without special cases for XHTML 162 // element like this, without special cases for XHTML
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 emitsMinus = ch == '-'; 560 emitsMinus = ch == '-';
560 builder.append(ch); 561 builder.append(ch);
561 } 562 }
562 CString escapedUrl = builder.toString().ascii(); 563 CString escapedUrl = builder.toString().ascii();
563 return String::format("saved from url=(%04d)%s", 564 return String::format("saved from url=(%04d)%s",
564 static_cast<int>(escapedUrl.length()), 565 static_cast<int>(escapedUrl.length()),
565 escapedUrl.data()); 566 escapedUrl.data());
566 } 567 }
567 568
568 } // namespace blink 569 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameSerializer.h ('k') | third_party/WebKit/Source/web/WebFrameSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698