| Index: content/common/content_security_policy/content_security_policy.cc
|
| diff --git a/content/common/content_security_policy/content_security_policy.cc b/content/common/content_security_policy/content_security_policy.cc
|
| index 87b035eb1c2ef44916452f1ea3e186ae29f75d64..299a4c2468cb3921ae60cddb40cd8d12f74bfb63 100644
|
| --- a/content/common/content_security_policy/content_security_policy.cc
|
| +++ b/content/common/content_security_policy/content_security_policy.cc
|
| @@ -50,6 +50,15 @@ void ReportViolation(CSPContext* context,
|
| DCHECK_NE(directive_name, CSPDirective::DefaultSrc);
|
| DCHECK_NE(directive_name, CSPDirective::ChildSrc);
|
|
|
| + // For security reasons, some urls must not be disclosed. This includes the
|
| + // blocked url and the source location of the error. Care must be taken to
|
| + // ensure that these are not transmitted between different cross-origin
|
| + // renderers.
|
| + GURL safe_url = url;
|
| + SourceLocation safe_source_location = source_location;
|
| + context->SanitizeDataForUseInCspViolation(is_redirect, directive_name,
|
| + &safe_url, &safe_source_location);
|
| +
|
| std::stringstream message;
|
|
|
| if (policy.header.type == blink::kWebContentSecurityPolicyTypeReport)
|
| @@ -60,7 +69,7 @@ void ReportViolation(CSPContext* context,
|
| else if (directive_name == CSPDirective::FrameSrc)
|
| message << "Refused to frame '";
|
|
|
| - message << ElideURLForReportViolation(url)
|
| + message << ElideURLForReportViolation(safe_url)
|
| << "' because it violates the following Content Security Policy "
|
| "directive: \""
|
| << directive.ToString() << "\".";
|
| @@ -75,9 +84,9 @@ void ReportViolation(CSPContext* context,
|
|
|
| context->ReportContentSecurityPolicyViolation(CSPViolationParams(
|
| CSPDirective::NameToString(directive.name),
|
| - CSPDirective::NameToString(directive_name), message.str(), url,
|
| + CSPDirective::NameToString(directive_name), message.str(), safe_url,
|
| policy.report_endpoints, policy.header.header_value, policy.header.type,
|
| - is_redirect, source_location));
|
| + is_redirect, safe_source_location));
|
| }
|
|
|
| bool AllowDirective(CSPContext* context,
|
|
|