Diff
Modified: trunk/LayoutTests/ChangeLog (202154 => 202155)
--- trunk/LayoutTests/ChangeLog 2016-06-17 02:50:30 UTC (rev 202154)
+++ trunk/LayoutTests/ChangeLog 2016-06-17 03:51:00 UTC (rev 202155)
@@ -1,3 +1,26 @@
+2016-06-16 Jiewen Tan <[email protected]>
+
+ CSP: Content Security Policy should allow '*' to match the originating page's scheme
+ https://bugs.webkit.org/show_bug.cgi?id=158811
+ <rdar://problem/26819568>
+
+ Reviewed by Daniel Bates.
+
+ * security/contentSecurityPolicy/image-with-file-url-allowed-by-img-src-star-expected.html: Added.
+ * security/contentSecurityPolicy/image-with-file-url-allowed-by-img-src-star.html: Added.
+ * security/contentSecurityPolicy/image-with-file-url-blocked-by-img-src-star-expected.html: Removed.
+ * security/contentSecurityPolicy/image-with-file-url-blocked-by-img-src-star.html: Removed.
+ * security/contentSecurityPolicy/link-with-file-url-allowed-by-style-src-star-expected.html: Added.
+ * security/contentSecurityPolicy/link-with-file-url-allowed-by-style-src-star.html: Added.
+ * security/contentSecurityPolicy/link-with-file-url-blocked-by-style-src-star-expected.html: Removed.
+ * security/contentSecurityPolicy/link-with-file-url-blocked-by-style-src-star.html: Removed.
+ * security/contentSecurityPolicy/resources/alert-pass.js: Added.
+ * security/contentSecurityPolicy/script-with-file-url-allowed-by-script-src-star-expected.txt: Added.
+ * security/contentSecurityPolicy/script-with-file-url-allowed-by-script-src-star.html: Added.
+ * security/contentSecurityPolicy/video-with-file-url-allowed-by-media-src-star-expected.html: Copied from LayoutTests/security/contentSecurityPolicy/video-with-file-url-blocked-by-media-src-star.html.
+ * security/contentSecurityPolicy/video-with-file-url-allowed-by-media-src-star.html: Renamed from LayoutTests/security/contentSecurityPolicy/video-with-file-url-blocked-by-media-src-star.html.
+ * security/contentSecurityPolicy/video-with-file-url-blocked-by-media-src-star-expected.html: Removed.
+
2016-06-16 Joseph Pecoraro <[email protected]>
Web Inspector: console.profile should use the new Sampling Profiler
Added: trunk/LayoutTests/security/contentSecurityPolicy/image-with-file-url-allowed-by-img-src-star-expected.html (0 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/image-with-file-url-allowed-by-img-src-star-expected.html (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/image-with-file-url-allowed-by-img-src-star-expected.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that loading image with a file URL is allowed when the page that is loaded from file URL has Content Security Policy "image-src *". This test PASSED if you see a green square below. Otherwise, it FAILED.</p>
+<img src="" width="128" height="128">
+</body>
+</html>
Added: trunk/LayoutTests/security/contentSecurityPolicy/image-with-file-url-allowed-by-img-src-star.html (0 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/image-with-file-url-allowed-by-img-src-star.html (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/image-with-file-url-allowed-by-img-src-star.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Security-Policy" content="img-src *">
+</head>
+<body>
+<p>This tests that loading image with a file URL is allowed when the page that is loaded from file URL has Content Security Policy "image-src *". This test PASSED if you see a green square below. Otherwise, it FAILED.</p>
+<img src="" width="128" height="128">
+</body>
+</html>
Deleted: trunk/LayoutTests/security/contentSecurityPolicy/image-with-file-url-blocked-by-img-src-star-expected.html (202154 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/image-with-file-url-blocked-by-img-src-star-expected.html 2016-06-17 02:50:30 UTC (rev 202154)
+++ trunk/LayoutTests/security/contentSecurityPolicy/image-with-file-url-blocked-by-img-src-star-expected.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -1,7 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-<p>This tests that loading image with a file URL is blocked when the page has Content Security Policy "image-src *". This test PASSED if you see the word PASS below. Otherwise, it FAILED.</p>
-<img src="" width="128" height="128" alt="PASS">
-</body>
-</html>
Deleted: trunk/LayoutTests/security/contentSecurityPolicy/image-with-file-url-blocked-by-img-src-star.html (202154 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/image-with-file-url-blocked-by-img-src-star.html 2016-06-17 02:50:30 UTC (rev 202154)
+++ trunk/LayoutTests/security/contentSecurityPolicy/image-with-file-url-blocked-by-img-src-star.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta http-equiv="Content-Security-Policy" content="img-src *">
-</head>
-<body>
-<p>This tests that loading image with a file URL is blocked when the page has Content Security Policy "image-src *". This test PASSED if you see the word PASS below. Otherwise, it FAILED.</p>
-<img src="" width="128" height="128" alt="PASS">
-</body>
-</html>
Added: trunk/LayoutTests/security/contentSecurityPolicy/link-with-file-url-allowed-by-style-src-star-expected.html (0 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/link-with-file-url-allowed-by-style-src-star-expected.html (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/link-with-file-url-allowed-by-style-src-star-expected.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that loading a stylesheet with a file URL is allowed when the page that is loaded from file URL has Content Security Policy "style-src *". This test PASSED if you see a green square below. Otherwise, it FAILED.</p>
+<div style="background-color: green; height: 128px; width: 128px"></div>
+</body>
+</html>
Added: trunk/LayoutTests/security/contentSecurityPolicy/link-with-file-url-allowed-by-style-src-star.html (0 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/link-with-file-url-allowed-by-style-src-star.html (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/link-with-file-url-allowed-by-style-src-star.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#test {
+ background-color: red;
+ height: 128px;
+ width: 128px;
+}
+</style>
+<meta http-equiv="Content-Security-Policy" content="style-src *">
+<link rel="stylesheet" href=""
+</head>
+<body>
+<p>This tests that loading a stylesheet with a file URL is allowed when the page that is loaded from file URL has Content Security Policy "style-src *". This test PASSED if you see a green square below. Otherwise, it FAILED.</p>
+<div id="test"></div>
+</body>
+</html>
Deleted: trunk/LayoutTests/security/contentSecurityPolicy/link-with-file-url-blocked-by-style-src-star-expected.html (202154 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/link-with-file-url-blocked-by-style-src-star-expected.html 2016-06-17 02:50:30 UTC (rev 202154)
+++ trunk/LayoutTests/security/contentSecurityPolicy/link-with-file-url-blocked-by-style-src-star-expected.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -1,7 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-<p>This tests that loading a stylesheet with a file URL is blocked when the page has Content Security Policy "style-src *". This test PASSED if you see a green square below. Otherwise, it FAILED.</p>
-<div style="background-color: green; height: 128px; width: 128px"></div>
-</body>
-</html>
Deleted: trunk/LayoutTests/security/contentSecurityPolicy/link-with-file-url-blocked-by-style-src-star.html (202154 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/link-with-file-url-blocked-by-style-src-star.html 2016-06-17 02:50:30 UTC (rev 202154)
+++ trunk/LayoutTests/security/contentSecurityPolicy/link-with-file-url-blocked-by-style-src-star.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -1,18 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<style>
-#test {
- background-color: green;
- height: 128px;
- width: 128px;
-}
-</style>
-<meta http-equiv="Content-Security-Policy" content="style-src *">
-<link rel="stylesheet" href=""
-</head>
-<body>
-<p>This tests that loading a stylesheet with a file URL is blocked when the page has Content Security Policy "style-src *". This test PASSED if you see a green square below. Otherwise, it FAILED.</p>
-<div id="test"></div>
-</body>
-</html>
Added: trunk/LayoutTests/security/contentSecurityPolicy/resources/alert-pass.js (0 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/resources/alert-pass.js (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/resources/alert-pass.js 2016-06-17 03:51:00 UTC (rev 202155)
@@ -0,0 +1 @@
+alert("PASS");
Added: trunk/LayoutTests/security/contentSecurityPolicy/script-with-file-url-allowed-by-script-src-star-expected.txt (0 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/script-with-file-url-allowed-by-script-src-star-expected.txt (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/script-with-file-url-allowed-by-script-src-star-expected.txt 2016-06-17 03:51:00 UTC (rev 202155)
@@ -0,0 +1,2 @@
+ALERT: PASS
+Test passes if the _javascript_ script is loaded.
Added: trunk/LayoutTests/security/contentSecurityPolicy/script-with-file-url-allowed-by-script-src-star.html (0 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/script-with-file-url-allowed-by-script-src-star.html (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/script-with-file-url-allowed-by-script-src-star.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+</script>
+<meta http-equiv="Content-Security-Policy" content="script-src *">
+</head>
+<body>
+<p>Test passes if the _javascript_ script is loaded.</p>
+<script src=""
+</body>
+</html>
Copied: trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-allowed-by-media-src-star-expected.html (from rev 202154, trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-blocked-by-media-src-star.html) (0 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-allowed-by-media-src-star-expected.html (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-allowed-by-media-src-star-expected.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+video {
+ background-color: red;
+ width: 128px;
+ height: 128px;
+}
+</style>
+<script src=""
+<script>
+if (window.testRunner)
+ testRunner.waitUntilDone();
+
+ function testFinished()
+{
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+ window._onload_ = function ()
+{
+ var video = document.getElementById("video");
+ video._oncanplaythrough_ = function () {
+ // Use a zero timer to ensure that the first frame of the video is drawn.
+ window.setTimeout(testFinished, 0);
+ }
+ video._onerror_ = testFinished;
+ video.src = "" + findMediaFile("video", "content/test");
+}
+</script>
+</head>
+<body>
+<p>This tests that loading a video with a file URL is allowed when the page that is loaded from file URL has Content Security Policy "media-src *". This test PASSED if you don't see a solid red square. Otherwise, it FAILED.</p>
+<video id="video"></video>
Copied: trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-allowed-by-media-src-star.html (from rev 202154, trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-blocked-by-media-src-star.html) (0 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-allowed-by-media-src-star.html (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-allowed-by-media-src-star.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Security-Policy" content="media-src *">
+<style>
+video {
+ background-color: red;
+ width: 128px;
+ height: 128px;
+}
+</style>
+<script src=""
+<script>
+if (window.testRunner)
+ testRunner.waitUntilDone();
+
+ function testFinished()
+{
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+ window._onload_ = function ()
+{
+ var video = document.getElementById("video");
+ video._oncanplaythrough_ = function () {
+ // Use a zero timer to ensure that the first frame of the video is drawn.
+ window.setTimeout(testFinished, 0);
+ }
+ video._onerror_ = testFinished;
+ video.src = "" + findMediaFile("video", "content/test");
+}
+</script>
+</head>
+<body>
+<p>This tests that loading a video with a file URL is allowed when the page that is loaded from file URL has Content Security Policy "media-src *". This test PASSED if you don't see a solid red square. Otherwise, it FAILED.</p>
+<video id="video"></video>
+</body>
+</html>
Deleted: trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-blocked-by-media-src-star-expected.html (202154 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-blocked-by-media-src-star-expected.html 2016-06-17 02:50:30 UTC (rev 202154)
+++ trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-blocked-by-media-src-star-expected.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<style>
-#equivalent-expected-result {
- background-color: green;
- width: 128px;
- height: 128px;
-}
-</style>
-</head>
-<body>
-<p>This tests that loading a video with a file URL is blocked when the page has Content Security Policy "media-src *". This test PASSED if you see a solid green square. Otherwise, it FAILED.</p>
-<div id="equivalent-expected-result"></div>
-</body>
-</html>
Deleted: trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-blocked-by-media-src-star.html (202154 => 202155)
--- trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-blocked-by-media-src-star.html 2016-06-17 02:50:30 UTC (rev 202154)
+++ trunk/LayoutTests/security/contentSecurityPolicy/video-with-file-url-blocked-by-media-src-star.html 2016-06-17 03:51:00 UTC (rev 202155)
@@ -1,39 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta http-equiv="Content-Security-Policy" content="media-src *">
-<style>
-video {
- background-color: green;
- width: 128px;
- height: 128px;
-}
-</style>
-<script src=""
-<script>
-if (window.testRunner)
- testRunner.waitUntilDone();
-
-function testFinished()
-{
- if (window.testRunner)
- testRunner.notifyDone();
-}
-
-window._onload_ = function ()
-{
- var video = document.getElementById("video");
- video._oncanplaythrough_ = function () {
- // Use a zero timer to ensure that the first frame of the video is drawn.
- window.setTimeout(testFinished, 0);
- }
- video._onerror_ = testFinished;
- video.src = "" + findMediaFile("video", "content/test");
-}
-</script>
-</head>
-<body>
-<p>This tests that loading a video with a file URL is blocked when the page has Content Security Policy "media-src *". This test PASSED if you see a solid green square. Otherwise, it FAILED.</p>
-<video id="video"></video>
-</body>
-</html>
Modified: trunk/Source/WebCore/ChangeLog (202154 => 202155)
--- trunk/Source/WebCore/ChangeLog 2016-06-17 02:50:30 UTC (rev 202154)
+++ trunk/Source/WebCore/ChangeLog 2016-06-17 03:51:00 UTC (rev 202155)
@@ -1,3 +1,19 @@
+2016-06-16 Jiewen Tan <[email protected]>
+
+ CSP: Content Security Policy should allow '*' to match the originating page's scheme
+ https://bugs.webkit.org/show_bug.cgi?id=158811
+ <rdar://problem/26819568>
+
+ Reviewed by Daniel Bates.
+
+ Tests: security/contentSecurityPolicy/image-with-file-url-allowed-by-img-src-star.html
+ security/contentSecurityPolicy/link-with-file-url-allowed-by-style-src-star.html
+ security/contentSecurityPolicy/script-with-file-url-allowed-by-script-src-star.html
+ security/contentSecurityPolicy/video-with-file-url-allowed-by-media-src-star.html
+
+ * page/csp/ContentSecurityPolicySourceList.cpp:
+ (WebCore::ContentSecurityPolicySourceList::isProtocolAllowedByStar):
+
2016-06-16 Chris Dumez <[email protected]>
Add HTTPHeaderMap::set() overload taking a NSString*
Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp (202154 => 202155)
--- trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp 2016-06-17 02:50:30 UTC (rev 202154)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp 2016-06-17 03:51:00 UTC (rev 202155)
@@ -123,7 +123,7 @@
// Although not allowed by the Content Security Policy Level 3 spec., we allow a data URL to match
// "img-src *" and either a data URL or blob URL to match "media-src *" for web compatibility.
- bool isAllowed = url.protocolIsInHTTPFamily();
+ bool isAllowed = url.protocolIsInHTTPFamily() || m_policy.protocolMatchesSelf(url);
if (equalIgnoringASCIICase(m_directiveName, ContentSecurityPolicyDirectiveNames::imgSrc))
isAllowed |= url.protocolIsData();
else if (equalIgnoringASCIICase(m_directiveName, ContentSecurityPolicyDirectiveNames::mediaSrc))