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

Side by Side 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 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 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
6 * reserved. 6 * reserved.
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 284
285 if (document().isSandboxed(SandboxForms)) { 285 if (document().isSandboxed(SandboxForms)) {
286 document().addConsoleMessage(ConsoleMessage::create( 286 document().addConsoleMessage(ConsoleMessage::create(
287 SecurityMessageSource, ErrorMessageLevel, 287 SecurityMessageSource, ErrorMessageLevel,
288 "Blocked form submission to '" + m_attributes.action() + 288 "Blocked form submission to '" + m_attributes.action() +
289 "' because the form's frame is sandboxed and the 'allow-forms' " 289 "' because the form's frame is sandboxed and the 'allow-forms' "
290 "permission is not set.")); 290 "permission is not set."));
291 return; 291 return;
292 } 292 }
293 293
294 // https://github.com/whatwg/html/issues/2253
295 for (const auto& element : listedElements()) {
296 if (element->isFormControlElement() &&
297 toHTMLFormControlElement(element)->blocksFormSubmission()) {
298 UseCounter::count(document(),
299 UseCounter::FormSubmittedWithUnclosedFormControl);
300 if (RuntimeEnabledFeatures::unclosedFormControlIsInvalidEnabled()) {
301 String tagName = toHTMLFormControlElement(element)->tagName();
302 document().addConsoleMessage(ConsoleMessage::create(
303 SecurityMessageSource, ErrorMessageLevel,
304 "Form submission failed, as the <" + tagName + "> element named "
305 "'" + element->name() + "' was implicitly closed by reaching "
306 "the end of the file. Please add an explicit end tag "
307 "('</" + tagName + ">')"));
308 dispatchEvent(Event::create(EventTypeNames::error));
309 return;
310 }
311 }
312 }
313
294 bool skipValidation = !document().page() || noValidate(); 314 bool skipValidation = !document().page() || noValidate();
295 DCHECK(event); 315 DCHECK(event);
296 if (submitButton && submitButton->formNoValidate()) 316 if (submitButton && submitButton->formNoValidate())
297 skipValidation = true; 317 skipValidation = true;
298 318
299 UseCounter::count(document(), UseCounter::FormSubmissionStarted); 319 UseCounter::count(document(), UseCounter::FormSubmissionStarted);
300 // Interactive validation must be done before dispatching the submit event. 320 // Interactive validation must be done before dispatching the submit event.
301 if (!skipValidation && !validateInteractively()) 321 if (!skipValidation && !validateInteractively())
302 return; 322 return;
303 323
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 for (const auto& control : listedElements()) { 826 for (const auto& control : listedElements()) {
807 if (!control->isFormControlElement()) 827 if (!control->isFormControlElement())
808 continue; 828 continue;
809 if (toHTMLFormControlElement(control)->canBeSuccessfulSubmitButton()) 829 if (toHTMLFormControlElement(control)->canBeSuccessfulSubmitButton())
810 toHTMLFormControlElement(control)->pseudoStateChanged( 830 toHTMLFormControlElement(control)->pseudoStateChanged(
811 CSSSelector::PseudoDefault); 831 CSSSelector::PseudoDefault);
812 } 832 }
813 } 833 }
814 834
815 } // namespace blink 835 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698