12011-02-18 Adam Barth <abarth@webkit.org>
2
3 Reviewed by NOBODY (OOPS!).
4
5 CSP's script-src should block JavaScript URLs
6 https://bugs.webkit.org/show_bug.cgi?id=54787
7
8 Blocking JavaScript URLs required some re-architecting of the lifetime
9 of the ContentSecurityPolicy object. We now manage the lifetime the
10 same way we manage the lifetime of the SecurityOrigin object. In
11 particular, when SecurityOrigin inherits into an about:blank iframe, we
12 inherit the CSP object as well. (This is covered by the test added in
13 this patch.) In the future, we might consider making
14 ContentSecurityPolicy a component of SecurityOrigin instead of a
15 component of Document.
16
17 I noted the trickiness in
18 http://www.w3.org/Security/wiki/Content_Security_Policies so that we'll
19 make sure it gets defined properly in the spec.
20
21 Test: http/tests/security/contentSecurityPolicy/javascript-url.html
22
23 * bindings/ScriptControllerBase.cpp:
24 (WebCore::ScriptController::executeIfJavaScriptURL):
25 * dom/Document.cpp:
26 (WebCore::Document::initSecurityContext):
27 * dom/Document.h:
28 (WebCore::Document::contentSecurityPolicy):
29 * page/ContentSecurityPolicy.cpp:
30 (WebCore::ContentSecurityPolicy::allowJavaScriptURLs):
31 * page/ContentSecurityPolicy.h:
32 (WebCore::ContentSecurityPolicy::create):
33