Bug 529697 - (CSP 1.1) Implement form-action directive [2/4], r=smaug
Check CSP when submitting HTML forms.
This commit is contained in:
@@ -61,6 +61,8 @@
|
||||
#include "nsIDOMHTMLButtonElement.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
|
||||
// images
|
||||
#include "mozilla/dom/HTMLImageElement.h"
|
||||
|
||||
@@ -1625,6 +1627,19 @@ HTMLFormElement::GetActionURL(nsIURI** aActionURL,
|
||||
nsIScriptSecurityManager::STANDARD);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Check if CSP allows this form-action
|
||||
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
||||
rv = NodePrincipal()->GetCsp(getter_AddRefs(csp));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (csp) {
|
||||
bool permitsFormAction = true;
|
||||
rv = csp->PermitsFormAction(actionURL, &permitsFormAction);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!permitsFormAction) {
|
||||
rv = NS_ERROR_CSP_FORM_ACTION_VIOLATION;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Assign to the output
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user