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

Unified Diff: third_party/WebKit/Source/web/WebFrameSerializer.cpp

Issue 2560693002: Disable form elements in MHTML (Closed)
Patch Set: Patch 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/web/WebFrameSerializer.cpp
diff --git a/third_party/WebKit/Source/web/WebFrameSerializer.cpp b/third_party/WebKit/Source/web/WebFrameSerializer.cpp
index e5e719e323f6557ce0df120451e1fb8c415d6369..61c70cbb6c9b52a994e09de175297d3b19ec5d3f 100644
--- a/third_party/WebKit/Source/web/WebFrameSerializer.cpp
+++ b/third_party/WebKit/Source/web/WebFrameSerializer.cpp
@@ -85,6 +85,7 @@ class MHTMLFrameSerializerDelegate final : public FrameSerializer::Delegate {
bool rewriteLink(const Element&, String& rewrittenLink) override;
bool shouldSkipResourceWithURL(const KURL&) override;
bool shouldSkipResource(const Resource&) override;
+ Vector<Attribute> getCustomAttributes(const Element&) override;
private:
WebFrameSerializer::MHTMLPartsGenerationDelegate& m_webDelegate;
@@ -166,6 +167,30 @@ bool MHTMLFrameSerializerDelegate::shouldSkipResource(
resource.hasCacheControlNoStoreHeader();
}
+Vector<Attribute> MHTMLFrameSerializerDelegate::getCustomAttributes(
+ const Element& element) {
+ Vector<Attribute> attributes;
+
+ // Disable all form elements in MTHML to tell the user that the form cannot be
+ // worked on. MHTML is loaded in full sandboxing mode which disable the form
+ // submission and script execution.
+ if (element.isFormControlElement()) {
+ bool hasDisabledAttribute = false;
+ for (const auto& attribute : element.attributes()) {
carlosk 2016/12/07 21:07:23 Using one of Element's own methods methods to do t
jianli 2016/12/07 22:10:48 Done.
+ if (attribute.name() == HTMLNames::disabledAttr) {
+ hasDisabledAttribute = true;
+ break;
+ }
+ }
+ if (!hasDisabledAttribute) {
+ Attribute disabledAttribute(HTMLNames::disabledAttr, "");
+ attributes.append(disabledAttribute);
+ }
+ }
+
+ return attributes;
+}
+
bool cacheControlNoStoreHeaderPresent(
const WebLocalFrameImpl& webLocalFrameImpl) {
const ResourceResponse& response =

Powered by Google App Engine
This is Rietveld 408576698