OLD | NEW |
---|---|
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 reserv ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. |
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 19 matching lines...) Expand all Loading... | |
30 #include "bindings/v8/ScriptController.h" | 30 #include "bindings/v8/ScriptController.h" |
31 #include "bindings/v8/ScriptEventListener.h" | 31 #include "bindings/v8/ScriptEventListener.h" |
32 #include "core/dom/Attribute.h" | 32 #include "core/dom/Attribute.h" |
33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
34 #include "core/dom/ElementTraversal.h" | 34 #include "core/dom/ElementTraversal.h" |
35 #include "core/dom/IdTargetObserverRegistry.h" | 35 #include "core/dom/IdTargetObserverRegistry.h" |
36 #include "core/events/AutocompleteErrorEvent.h" | 36 #include "core/events/AutocompleteErrorEvent.h" |
37 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
38 #include "core/events/GenericEventQueue.h" | 38 #include "core/events/GenericEventQueue.h" |
39 #include "core/events/ScopedEventQueue.h" | 39 #include "core/events/ScopedEventQueue.h" |
40 #include "core/frame/DOMWindow.h" | |
41 #include "core/frame/LocalFrame.h" | |
42 #include "core/frame/UseCounter.h" | |
43 #include "core/frame/csp/ContentSecurityPolicy.h" | |
40 #include "core/html/HTMLCollection.h" | 44 #include "core/html/HTMLCollection.h" |
41 #include "core/html/HTMLDialogElement.h" | 45 #include "core/html/HTMLDialogElement.h" |
42 #include "core/html/HTMLImageElement.h" | 46 #include "core/html/HTMLImageElement.h" |
43 #include "core/html/HTMLInputElement.h" | 47 #include "core/html/HTMLInputElement.h" |
44 #include "core/html/HTMLObjectElement.h" | 48 #include "core/html/HTMLObjectElement.h" |
45 #include "core/html/RadioNodeList.h" | 49 #include "core/html/RadioNodeList.h" |
46 #include "core/html/forms/FormController.h" | 50 #include "core/html/forms/FormController.h" |
47 #include "core/loader/FrameLoader.h" | 51 #include "core/loader/FrameLoader.h" |
48 #include "core/loader/FrameLoaderClient.h" | 52 #include "core/loader/FrameLoaderClient.h" |
49 #include "core/frame/DOMWindow.h" | 53 #include "core/loader/MixedContentChecker.h" |
50 #include "core/frame/LocalFrame.h" | |
51 #include "core/frame/UseCounter.h" | |
52 #include "core/frame/csp/ContentSecurityPolicy.h" | |
53 #include "core/rendering/RenderTextControl.h" | 54 #include "core/rendering/RenderTextControl.h" |
54 #include "platform/UserGestureIndicator.h" | 55 #include "platform/UserGestureIndicator.h" |
56 #include "wtf/text/AtomicString.h" | |
55 | 57 |
56 using namespace std; | 58 using namespace std; |
57 | 59 |
58 namespace WebCore { | 60 namespace WebCore { |
59 | 61 |
60 using namespace HTMLNames; | 62 using namespace HTMLNames; |
61 | 63 |
64 namespace { | |
65 | |
66 KURL getActionURL(const Document& document, const String& action) | |
67 { | |
68 return action.isEmpty() ? document.url() : document.completeURL(action); | |
69 } | |
70 | |
71 } // namespace | |
72 | |
62 HTMLFormElement::HTMLFormElement(Document& document) | 73 HTMLFormElement::HTMLFormElement(Document& document) |
63 : HTMLElement(formTag, document) | 74 : HTMLElement(formTag, document) |
64 #if !ENABLE(OILPAN) | 75 #if !ENABLE(OILPAN) |
65 , m_weakPtrFactory(this) | 76 , m_weakPtrFactory(this) |
66 #endif | 77 #endif |
67 , m_associatedElementsAreDirty(false) | 78 , m_associatedElementsAreDirty(false) |
68 , m_imageElementsAreDirty(false) | 79 , m_imageElementsAreDirty(false) |
69 , m_hasElementsAssociatedByParser(false) | 80 , m_hasElementsAssociatedByParser(false) |
70 , m_didFinishParsingChildren(false) | 81 , m_didFinishParsingChildren(false) |
71 , m_wasUserSubmitted(false) | 82 , m_wasUserSubmitted(false) |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 | 351 |
341 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce ssingUserGesture, FormSubmissionTrigger formSubmissionTrigger) | 352 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce ssingUserGesture, FormSubmissionTrigger formSubmissionTrigger) |
342 { | 353 { |
343 FrameView* view = document().view(); | 354 FrameView* view = document().view(); |
344 LocalFrame* frame = document().frame(); | 355 LocalFrame* frame = document().frame(); |
345 if (!view || !frame || !frame->page()) | 356 if (!view || !frame || !frame->page()) |
346 return; | 357 return; |
347 | 358 |
348 m_wasUserSubmitted = processingUserGesture; | 359 m_wasUserSubmitted = processingUserGesture; |
349 | 360 |
361 KURL actionURL = getActionURL(document(), m_attributes.action()); | |
362 if (MixedContentChecker::isMixedContent(document().securityOrigin(), actionU RL)) | |
363 UseCounter::count(document(), UseCounter::MixedContentSubmittedForm); | |
364 | |
365 if (!document().frame()->loader().mixedContentChecker()->canSubmitToInsecure Form(document().securityOrigin(), actionURL)) | |
366 return; | |
367 | |
350 RefPtrWillBeRawPtr<HTMLFormControlElement> firstSuccessfulSubmitButton = nul lptr; | 368 RefPtrWillBeRawPtr<HTMLFormControlElement> firstSuccessfulSubmitButton = nul lptr; |
351 bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button? | 369 bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button? |
352 | 370 |
353 const FormAssociatedElement::List& elements = associatedElements(); | 371 const FormAssociatedElement::List& elements = associatedElements(); |
354 for (unsigned i = 0; i < elements.size(); ++i) { | 372 for (unsigned i = 0; i < elements.size(); ++i) { |
355 FormAssociatedElement* associatedElement = elements[i]; | 373 FormAssociatedElement* associatedElement = elements[i]; |
356 if (!associatedElement->isFormControlElement()) | 374 if (!associatedElement->isFormControlElement()) |
357 continue; | 375 continue; |
358 if (needButtonActivation) { | 376 if (needButtonActivation) { |
359 HTMLFormControlElement* control = toHTMLFormControlElement(associate dElement); | 377 HTMLFormControlElement* control = toHTMLFormControlElement(associate dElement); |
(...skipping 22 matching lines...) Expand all Loading... | |
382 { | 400 { |
383 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met hod() == FormSubmission::GetMethod); | 401 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met hod() == FormSubmission::GetMethod); |
384 ASSERT(submission->data()); | 402 ASSERT(submission->data()); |
385 ASSERT(submission->state()); | 403 ASSERT(submission->state()); |
386 if (submission->action().isEmpty()) | 404 if (submission->action().isEmpty()) |
387 return; | 405 return; |
388 if (document().isSandboxed(SandboxForms)) { | 406 if (document().isSandboxed(SandboxForms)) { |
389 // FIXME: This message should be moved off the console once a solution t o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 407 // FIXME: This message should be moved off the console once a solution t o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
390 document().addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, " Blocked form submission to '" + submission->action().elidedString() + "' because the form's frame is sandboxed and the 'allow-forms' permission is not set."); | 408 document().addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, " Blocked form submission to '" + submission->action().elidedString() + "' because the form's frame is sandboxed and the 'allow-forms' permission is not set."); |
391 return; | 409 return; |
392 } | 410 } |
abarth-chromium
2014/06/07 08:59:50
It seems like we should do the mixed content check
mhm
2014/06/09 15:55:35
Done.
| |
393 | 411 |
394 if (protocolIsJavaScript(submission->action())) { | 412 if (protocolIsJavaScript(submission->action())) { |
395 if (!document().contentSecurityPolicy()->allowFormAction(KURL(submission ->action()))) | 413 if (!document().contentSecurityPolicy()->allowFormAction(KURL(submission ->action()))) |
396 return; | 414 return; |
397 document().frame()->script().executeScriptIfJavaScriptURL(submission->ac tion()); | 415 document().frame()->script().executeScriptIfJavaScriptURL(submission->ac tion()); |
398 return; | 416 return; |
399 } | 417 } |
400 | 418 |
401 LocalFrame* targetFrame = document().frame()->loader().findFrameForNavigatio n(submission->target(), submission->state()->sourceDocument()); | 419 LocalFrame* targetFrame = document().frame()->loader().findFrameForNavigatio n(submission->target(), submission->state()->sourceDocument()); |
402 if (!targetFrame) { | 420 if (!targetFrame) { |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 returnValue0 = radioNodeList(name, onlyMatchImg); | 801 returnValue0 = radioNodeList(name, onlyMatchImg); |
784 } | 802 } |
785 | 803 |
786 void HTMLFormElement::setDemoted(bool demoted) | 804 void HTMLFormElement::setDemoted(bool demoted) |
787 { | 805 { |
788 if (demoted) | 806 if (demoted) |
789 UseCounter::count(document(), UseCounter::DemotedFormElement); | 807 UseCounter::count(document(), UseCounter::DemotedFormElement); |
790 m_wasDemoted = demoted; | 808 m_wasDemoted = demoted; |
791 } | 809 } |
792 | 810 |
811 void HTMLFormElement::attributeChanged(const QualifiedName& name, const AtomicSt ring& newValue, AttributeModificationReason) | |
812 { | |
813 Element::attributeChanged(name, newValue); | |
814 if (name == actionAttr) { | |
815 // If the new action attribute is pointing to insecure "action" location from a secure page | |
816 // it is marked as "passive" mixed content. In other words, it will just | |
817 // show a console warning unless the user override the preferences to | |
818 // block all mixed content. | |
819 KURL actionURL = getActionURL(document(), m_attributes.action()); | |
820 if (MixedContentChecker::isMixedContent(document().securityOrigin(), act ionURL)) { | |
821 document().frame()->loader().mixedContentChecker()->canSubmitToInsec ureForm(document().securityOrigin(), actionURL); | |
822 UseCounter::count(document(), UseCounter::MixedContentForm); | |
823 } | |
824 } | |
abarth-chromium
2014/06/07 08:59:50
Is there a reason to trigger this use counter for
mhm
2014/06/09 15:55:35
mkwst@ suggested that we need to count three thing
| |
825 } | |
826 | |
793 } // namespace | 827 } // namespace |
OLD | NEW |