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

Unified Diff: third_party/WebKit/Source/core/html/HTMLFormElement.cpp

Issue 2628723004: Experiment with restricting form submission with open elements. (Closed)
Patch Set: Rebase. Created 3 years, 11 months 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/html/HTMLFormElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLFormElement.cpp b/third_party/WebKit/Source/core/html/HTMLFormElement.cpp
index 8385afdaf36d9d929e0c51b152c7117040b9b137..be254a2cb65d4f99371dd09284d5f0852b89e06b 100644
--- a/third_party/WebKit/Source/core/html/HTMLFormElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLFormElement.cpp
@@ -291,6 +291,26 @@ void HTMLFormElement::prepareForSubmission(
return;
}
+ // https://github.com/whatwg/html/issues/2253
+ for (const auto& element : listedElements()) {
+ if (element->isFormControlElement() &&
+ toHTMLFormControlElement(element)->blocksFormSubmission()) {
+ UseCounter::count(document(),
+ UseCounter::FormSubmittedWithUnclosedFormControl);
+ if (RuntimeEnabledFeatures::unclosedFormControlIsInvalidEnabled()) {
+ String tagName = toHTMLFormControlElement(element)->tagName();
+ document().addConsoleMessage(ConsoleMessage::create(
+ SecurityMessageSource, ErrorMessageLevel,
+ "Form submission failed, as the <" + tagName + "> element named "
+ "'" + element->name() + "' was implicitly closed by reaching "
+ "the end of the file. Please add an explicit end tag "
+ "('</" + tagName + ">')"));
+ dispatchEvent(Event::create(EventTypeNames::error));
+ return;
+ }
+ }
+ }
+
bool skipValidation = !document().page() || noValidate();
DCHECK(event);
if (submitButton && submitButton->formNoValidate())

Powered by Google App Engine
This is Rietveld 408576698