<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[199163] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/199163">199163</a></dd>
<dt>Author</dt> <dd>dbates@webkit.org</dd>
<dt>Date</dt> <dd>2016-04-07 11:03:04 -0700 (Thu, 07 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>CSP: Should only honor CSP policy delivered in meta tag that is a descendent of &lt;head&gt;
https://bugs.webkit.org/show_bug.cgi?id=59858
&lt;rdar://problem/25603538&gt;

Reviewed by Brent Fulgham.

Source/WebCore:

Ignore the Content Security Policy meta tag if it is not a descendent of &lt;head&gt; as per
section HTML meta Element of the Content Security Policy Level 2 spec., &lt;https://w3c.github.io/webappsec-csp/2/&gt;
(Editor's Draft, 29 August 2015).

Tests: http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head.html
       http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2.html
       http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head.html
       http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2.html

* dom/Document.cpp:
(WebCore::Document::processHttpEquiv): Modified to take a boolean argument whether the http-equiv
meta tag is a descendent of &lt;head&gt; and to parse the value of a Content Security Policy http-equiv
only if the http-equiv meta tag is a descendent of &lt;head&gt;.
* dom/Document.h: Add parameter isInDocument to processHttpEquiv(). Remove javadoc-style parameters
from processHttpEquiv() comment as we do not document parameters for non-API functions using such style.
Also write the comment for processHttpEquiv() using C++ style comments instead of a C-style comment.
* html/HTMLMetaElement.cpp:
(WebCore::HTMLMetaElement::process): Pass whether this element is a descendent of &lt;head&gt;. Additionally
update stale comment and move it closer to the code it refers to.

LayoutTests:

Add tests to ensure that we ignore the meta tags for Content-Security-Policy, Content-Security-Policy-Report-Only,
X-WebKit-CSP, and X-WebKit-CSP-Report-Only if it is not a descendent of &lt;head&gt;.

* http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head.html: Added.
* http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2.html: Added.
* http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head.html: Added.
* http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMetaElementcpp">trunk/Source/WebCore/html/HTMLMetaElement.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicymetatagignoredifnotinheadexpectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicymetatagignoredifnotinheadhtml">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicymetatagignoredifnotinhead2expectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicymetatagignoredifnotinhead2html">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportonlymetatagignoredifnotinheadexpectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportonlymetatagignoredifnotinheadhtml">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportonlymetatagignoredifnotinhead2expectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportonlymetatagignoredifnotinhead2html">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (199162 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-04-07 17:59:24 UTC (rev 199162)
+++ trunk/LayoutTests/ChangeLog        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-04-07  Daniel Bates  &lt;dabates@apple.com&gt;
+
+        CSP: Should only honor CSP policy delivered in meta tag that is a descendent of &lt;head&gt;
+        https://bugs.webkit.org/show_bug.cgi?id=59858
+        &lt;rdar://problem/25603538&gt;
+
+        Reviewed by Brent Fulgham.
+
+        Add tests to ensure that we ignore the meta tags for Content-Security-Policy, Content-Security-Policy-Report-Only,
+        X-WebKit-CSP, and X-WebKit-CSP-Report-Only if it is not a descendent of &lt;head&gt;.
+
+        * http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head-expected.txt: Added.
+        * http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head.html: Added.
+        * http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2-expected.txt: Added.
+        * http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2.html: Added.
+        * http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head-expected.txt: Added.
+        * http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head.html: Added.
+        * http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2-expected.txt: Added.
+        * http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2.html: Added.
+
</ins><span class="cx"> 2016-04-06  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         window.Crypto is missing
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicymetatagignoredifnotinheadexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head-expected.txt (0 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head-expected.txt        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that a &lt;meta http-equiv=&quot;Content-Security-Policy&quot;&gt; is ignored if it is not a descendent of &lt;head&gt;.
+
+PASS Content Security Policy was ignored.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicymetatagignoredifnotinheadhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head.html (0 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head.html        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+&lt;!DOCTYPE&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that a &amp;lt;meta http-equiv=&amp;quot;Content-Security-Policy&amp;quot;&amp;gt; is ignored if it is not a descendent of &amp;lt;head&amp;gt;.&lt;/p&gt;
+&lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;script-src 'self'&quot;&gt;
+&lt;p id=&quot;result&quot;&gt;FAIL Content Security Policy should have been ignored. But was honored.&lt;/p&gt;
+&lt;script&gt;
+document.getElementById(&quot;result&quot;).textContent = 'PASS Content Security Policy was ignored.';
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicymetatagignoredifnotinhead2expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2-expected.txt (0 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2-expected.txt        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This tests that a &lt;meta http-equiv=&quot;X-WebKit-CSP&quot;&gt; is ignored if it is not a descendent of &lt;head&gt;.
+
+PASS Content Security Policy was ignored.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicymetatagignoredifnotinhead2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2.html (0 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2.html        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+&lt;!DOCTYPE&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that a &amp;lt;meta http-equiv=&amp;quot;X-WebKit-CSP&amp;quot;&amp;gt; is ignored if it is not a descendent of &amp;lt;head&amp;gt;.&lt;/p&gt;
+&lt;meta http-equiv=&quot;X-WebKit-CSP&quot; content=&quot;script-src 'self'&quot;&gt;
+&lt;p id=&quot;result&quot;&gt;FAIL Content Security Policy should have been ignored. But was honored.&lt;/p&gt;
+&lt;script&gt;
+document.getElementById(&quot;result&quot;).textContent = 'PASS Content Security Policy was ignored.';
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportonlymetatagignoredifnotinheadexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head-expected.txt (0 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head-expected.txt        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+This tests that a &lt;meta http-equiv=&quot;Content-Security-Policy-Report-Only&quot;&gt; is ignored if it is not a descendent of &lt;head&gt;. This test PASSED if there are no console warnings. Otherwise, it FAILED.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportonlymetatagignoredifnotinheadhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head.html (0 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head.html        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+&lt;!DOCTYPE&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that a &amp;lt;meta http-equiv=&amp;quot;Content-Security-Policy-Report-Only&amp;quot;&amp;gt; is ignored if it is not a descendent of &amp;lt;head&amp;gt;. This test PASSED if there are no console warnings. Otherwise, it FAILED.&lt;/p&gt;
+&lt;meta http-equiv=&quot;Content-Security-Policy-Report-Only&quot; content=&quot;script-src 'self'&quot;&gt;
+&lt;script&gt;
+// Do nothing
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportonlymetatagignoredifnotinhead2expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2-expected.txt (0 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2-expected.txt        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+This tests that a &lt;meta http-equiv=&quot;X-WebKit-CSP-Report-Only&quot;&gt; is ignored if it is not a descendent of &lt;head&gt;. This test PASSED if there are no console warnings. Otherwise, it FAILED.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportonlymetatagignoredifnotinhead2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2.html (0 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2.html        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+&lt;!DOCTYPE&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that a &amp;lt;meta http-equiv=&amp;quot;X-WebKit-CSP-Report-Only&amp;quot;&amp;gt; is ignored if it is not a descendent of &amp;lt;head&amp;gt;. This test PASSED if there are no console warnings. Otherwise, it FAILED.&lt;/p&gt;
+&lt;meta http-equiv=&quot;X-WebKit-CSP-Report-Only&quot; content=&quot;script-src 'self'&quot;&gt;
+&lt;script&gt;
+// Do nothing
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (199162 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-07 17:59:24 UTC (rev 199162)
+++ trunk/Source/WebCore/ChangeLog        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2016-04-07  Daniel Bates  &lt;dabates@apple.com&gt;
+
+        CSP: Should only honor CSP policy delivered in meta tag that is a descendent of &lt;head&gt;
+        https://bugs.webkit.org/show_bug.cgi?id=59858
+        &lt;rdar://problem/25603538&gt;
+
+        Reviewed by Brent Fulgham.
+
+        Ignore the Content Security Policy meta tag if it is not a descendent of &lt;head&gt; as per
+        section HTML meta Element of the Content Security Policy Level 2 spec., &lt;https://w3c.github.io/webappsec-csp/2/&gt;
+        (Editor's Draft, 29 August 2015).
+
+        Tests: http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head.html
+               http/tests/security/contentSecurityPolicy/meta-tag-ignored-if-not-in-head2.html
+               http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head.html
+               http/tests/security/contentSecurityPolicy/report-only-meta-tag-ignored-if-not-in-head2.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::processHttpEquiv): Modified to take a boolean argument whether the http-equiv
+        meta tag is a descendent of &lt;head&gt; and to parse the value of a Content Security Policy http-equiv
+        only if the http-equiv meta tag is a descendent of &lt;head&gt;.
+        * dom/Document.h: Add parameter isInDocument to processHttpEquiv(). Remove javadoc-style parameters
+        from processHttpEquiv() comment as we do not document parameters for non-API functions using such style.
+        Also write the comment for processHttpEquiv() using C++ style comments instead of a C-style comment.
+        * html/HTMLMetaElement.cpp:
+        (WebCore::HTMLMetaElement::process): Pass whether this element is a descendent of &lt;head&gt;. Additionally
+        update stale comment and move it closer to the code it refers to.
+
</ins><span class="cx"> 2016-04-07  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] Output WebCore.pdb to the same location as WebCore.lib
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (199162 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2016-04-07 17:59:24 UTC (rev 199162)
+++ trunk/Source/WebCore/dom/Document.cpp        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -3219,9 +3219,10 @@
</span><span class="cx">     return authorSheets.usesStyleBasedEditability();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Document::processHttpEquiv(const String&amp; equiv, const String&amp; content)
</del><ins>+void Document::processHttpEquiv(const String&amp; equiv, const String&amp; content, bool isInDocumentHead)
</ins><span class="cx"> {
</span><del>-    ASSERT(!equiv.isNull() &amp;&amp; !content.isNull());
</del><ins>+    ASSERT(!equiv.isNull());
+    ASSERT(!content.isNull());
</ins><span class="cx"> 
</span><span class="cx">     HttpEquivPolicy policy = httpEquivPolicy();
</span><span class="cx">     if (policy != HttpEquivPolicy::Enabled) {
</span><span class="lines">@@ -3316,19 +3317,23 @@
</span><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case HTTPHeaderName::ContentSecurityPolicy:
</span><del>-        contentSecurityPolicy()-&gt;processHTTPEquiv(content, ContentSecurityPolicyHeaderType::Enforce);
</del><ins>+        if (isInDocumentHead)
+            contentSecurityPolicy()-&gt;processHTTPEquiv(content, ContentSecurityPolicyHeaderType::Enforce);
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case HTTPHeaderName::ContentSecurityPolicyReportOnly:
</span><del>-        contentSecurityPolicy()-&gt;processHTTPEquiv(content, ContentSecurityPolicyHeaderType::Report);
</del><ins>+        if (isInDocumentHead)
+            contentSecurityPolicy()-&gt;processHTTPEquiv(content, ContentSecurityPolicyHeaderType::Report);
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case HTTPHeaderName::XWebKitCSP:
</span><del>-        contentSecurityPolicy()-&gt;processHTTPEquiv(content, ContentSecurityPolicyHeaderType::PrefixedEnforce);
</del><ins>+        if (isInDocumentHead)
+            contentSecurityPolicy()-&gt;processHTTPEquiv(content, ContentSecurityPolicyHeaderType::PrefixedEnforce);
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case HTTPHeaderName::XWebKitCSPReportOnly:
</span><del>-        contentSecurityPolicy()-&gt;processHTTPEquiv(content, ContentSecurityPolicyHeaderType::PrefixedReport);
</del><ins>+        if (isInDocumentHead)
+            contentSecurityPolicy()-&gt;processHTTPEquiv(content, ContentSecurityPolicyHeaderType::PrefixedReport);
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     default:
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (199162 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h        2016-04-07 17:59:24 UTC (rev 199162)
+++ trunk/Source/WebCore/dom/Document.h        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -826,16 +826,11 @@
</span><span class="cx"> 
</span><span class="cx">     CSSStyleDeclaration* getOverrideStyle(Element*, const String&amp; pseudoElt);
</span><span class="cx"> 
</span><del>-    /**
-     * Handles a HTTP header equivalent set by a meta tag using &lt;meta http-equiv=&quot;...&quot; content=&quot;...&quot;&gt;. This is called
-     * when a meta tag is encountered during document parsing, and also when a script dynamically changes or adds a meta
-     * tag. This enables scripts to use meta tags to perform refreshes and set expiry dates in addition to them being
-     * specified in a HTML file.
-     *
-     * @param equiv The http header name (value of the meta tag's &quot;equiv&quot; attribute)
-     * @param content The header value (value of the meta tag's &quot;content&quot; attribute)
-     */
-    void processHttpEquiv(const String&amp; equiv, const String&amp; content);
</del><ins>+    // Handles an HTTP header equivalent set by a meta tag using &lt;meta http-equiv=&quot;...&quot; content=&quot;...&quot;&gt;. This is called
+    // when a meta tag is encountered during document parsing, and also when a script dynamically changes or adds a meta
+    // tag. This enables scripts to use meta tags to perform refreshes and set expiry dates in addition to them being
+    // specified in an HTML file.
+    void processHttpEquiv(const String&amp; equiv, const String&amp; content, bool isInDocumentHead);
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     void processFormatDetection(const String&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMetaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMetaElement.cpp (199162 => 199163)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMetaElement.cpp        2016-04-07 17:59:24 UTC (rev 199162)
+++ trunk/Source/WebCore/html/HTMLMetaElement.cpp        2016-04-07 18:03:04 UTC (rev 199163)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Attribute.h&quot;
</span><span class="cx"> #include &quot;Document.h&quot;
</span><ins>+#include &quot;HTMLHeadElement.h&quot;
</ins><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -64,6 +65,7 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLMetaElement::process()
</span><span class="cx"> {
</span><ins>+    // Changing a meta tag while it's not in the tree shouldn't have any effect on the document.
</ins><span class="cx">     if (!inDocument())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -82,11 +84,9 @@
</span><span class="cx">     else if (equalLettersIgnoringASCIICase(name(), &quot;referrer&quot;))
</span><span class="cx">         document().processReferrerPolicy(contentValue);
</span><span class="cx"> 
</span><del>-    // Get the document to process the tag, but only if we're actually part of DOM tree (changing a meta tag while
-    // it's not in the tree shouldn't have any effect on the document)
</del><span class="cx">     const AtomicString&amp; httpEquivValue = fastGetAttribute(http_equivAttr);
</span><span class="cx">     if (!httpEquivValue.isNull())
</span><del>-        document().processHttpEquiv(httpEquivValue, contentValue);
</del><ins>+        document().processHttpEquiv(httpEquivValue, contentValue, isDescendantOf(document().head()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const AtomicString&amp; HTMLMetaElement::content() const
</span></span></pre>
</div>
</div>

</body>
</html>