Skip to content

Commit 882803c

Browse files
committed
Define script@nonce and style@nonce attributes
The definitions here are little more than placeholders. We need to improve the description in CSP such that HTML can hook into reasonable definitions of the behavior that nonces require when executing the "prepare a script" and "update a style block" algorithms. For the moment, defining the attributes and pointing out to the CSP spec (and to w3c/webappsec#463) is probably Good Enough(tm).
1 parent 6fbd408 commit 882803c

File tree

1 file changed

+51
-8
lines changed

1 file changed

+51
-8
lines changed

source

+51-8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
! - element, attribute, content model, and interface indexes
1313
! - adding it to the section with ARIA mappings
1414
!
15+
! Adding a new attribute involves editing the following sections:
16+
! - The IDL and content attributes for the relevant elements
17+
! - element and attribute indexes
1518
!-->
1619

1720
<!--
@@ -14730,13 +14733,15 @@ people expect to have work and what is necessary.
1473014733
<dt><span data-x="concept-element-attributes">Content attributes</span>:</dt>
1473114734
<dd><span>Global attributes</span></dd>
1473214735
<dd><code data-x="attr-style-media">media</code></dd>
14736+
<dd><code data-x="attr-style-nonce">nonce</code></dd>
1473314737
<dd><code data-x="attr-style-type">type</code></dd>
1473414738
<dd><code data-x="attr-style-scoped">scoped</code></dd>
1473514739
<dd>Also, the <code data-x="attr-style-title">title</code> attribute <span data-x="attr-style-title">has special semantics</span> on this element.</dd>
1473614740
<dt><span data-x="concept-element-dom">DOM interface</span>:</dt><!--TOPIC:DOM APIs-->
1473714741
<dd>
1473814742
<pre class="idl">interface <dfn>HTMLStyleElement</dfn> : <span>HTMLElement</span> {
1473914743
attribute DOMString <span data-x="dom-style-media">media</span>;
14744+
attribute DOMString <span data-x="dom-style-nonce">nonce</span>;
1474014745
attribute DOMString <span data-x="dom-style-type">type</span>;
1474114746
attribute boolean <span data-x="dom-style-scoped">scoped</span>;
1474214747
};
@@ -14783,6 +14788,16 @@ people expect to have work and what is necessary.
1478314788
attribute is omitted, is "<code data-x="">all</code>", meaning that by default styles apply to all
1478414789
media.</p>
1478514790

14791+
<p>The <dfn><code data-x="attr-style-nonce">nonce</code></dfn> attribute represents a
14792+
cryptographic nonce ("number used once") which can be used by <cite>Content Security Policy</cite>
14793+
to determine whether or not the style specified by an element will be applied to the document. The
14794+
value is text. <ref spec="CSP"></p>
14795+
14796+
<p class="&#x0058;&#x0058;&#x0058;">The processing model for the <code
14797+
data-x="attr-style-nonce">nonce</code> attribute needs to be integrated into the <span>update a
14798+
<code>style</code> block</span> algorithm. The current definition in <ref spec="CSP"> is fairly
14799+
vague. See <a href="https://github.com/w3c/webappsec/issues/463">w3c/webappsec#463</a>.</p>
14800+
1478614801
<p>The <dfn><code data-x="attr-style-scoped">scoped</code></dfn> attribute is a <span>boolean
1478714802
attribute</span>. If present, it indicates that the styles are intended just for the subtree
1478814803
rooted at the <code>style</code> element's parent element, as opposed to the whole
@@ -14980,8 +14995,10 @@ own thing rather than part of the extended sentence -->
1498014995

1498114996
<div w-nodev>
1498214997

14983-
<p>The <dfn><code data-x="dom-style-media">media</code></dfn>, <dfn><code data-x="dom-style-type">type</code></dfn> and <dfn><code data-x="dom-style-scoped">scoped</code></dfn> IDL attributes must <span>reflect</span> the
14984-
respective content attributes of the same name.</p>
14998+
<p>The <dfn><code data-x="dom-style-media">media</code></dfn>, <dfn><code
14999+
data-x="dom-style-nonce">nonce</code></dfn>, <dfn><code data-x="dom-style-type">type</code></dfn>
15000+
and <dfn><code data-x="dom-style-scoped">scoped</code></dfn> IDL attributes must
15001+
<span>reflect</span> the respective content attributes of the same name.</p>
1498515002

1498615003
</div>
1498715004

@@ -58134,6 +58151,7 @@ dictionary <dfn>RelatedEventInit</dfn> : <span>EventInit</span> {
5813458151
<dd><code data-x="attr-script-async">async</code></dd>
5813558152
<dd><code data-x="attr-script-defer">defer</code></dd>
5813658153
<dd><code data-x="attr-script-crossorigin">crossorigin</code></dd>
58154+
<dd><code data-x="attr-script-nonce">nonce</code></dd>
5813758155
<dt><span data-x="concept-element-dom">DOM interface</span>:</dt><!--TOPIC:DOM APIs-->
5813858156
<dd>
5813958157
<pre class="idl">interface <dfn>HTMLScriptElement</dfn> : <span>HTMLElement</span> {
@@ -58144,6 +58162,7 @@ dictionary <dfn>RelatedEventInit</dfn> : <span>EventInit</span> {
5814458162
attribute boolean <span data-x="dom-script-defer">defer</span>;
5814558163
attribute DOMString? <span data-x="dom-script-crossOrigin">crossOrigin</span>;
5814658164
attribute DOMString <span data-x="dom-script-text">text</span>;
58165+
attribute DOMString <span data-x="dom-script-nonce">nonce</code>;
5814758166
};</pre>
5814858167
</dd>
5814958168
</dl><!--TOPIC:HTML-->
@@ -58220,11 +58239,23 @@ dictionary <dfn>RelatedEventInit</dfn> : <span>EventInit</span> {
5822058239
<span>CORS settings attribute</span>. It controls, for scripts that are obtained from other <span
5822158240
data-x="origin">origins</span>, whether error information will be exposed.</p>
5822258241

58242+
58243+
<p>The <dfn><code data-x="attr-style-nonce">nonce</code></dfn> attribute represents a
58244+
cryptographic nonce ("number used once") which can be used by <cite>Content Security Policy</cite>
58245+
to determine whether or not the script specified by an element will be executed. The value is
58246+
text. <ref spec="CSP"></p>
58247+
58248+
<p class="&#x0058;&#x0058;&#x0058;">The processing model for the <code
58249+
data-x="attr-script-nonce">nonce</code> attribute needs to be integrated into the <span>prepare a
58250+
script</span> algorithm. The current definition in <ref spec="CSP"> is fairly vague. See
58251+
<a href="https://github.com/w3c/webappsec/issues/463">w3c/webappsec#463</a>.</p>
58252+
5822358253
<p>Changing the <code data-x="attr-script-src">src</code>, <code
5822458254
data-x="attr-script-type">type</code>, <code data-x="attr-script-charset">charset</code>, <code
58225-
data-x="attr-script-async">async</code>, <code data-x="attr-script-defer">defer</code>, and <code
58226-
data-x="attr-script-crossorigin">crossorigin</code> attributes dynamically has no direct effect;
58227-
these attribute are only used at specific times described below.</p> <!-- by implication, changes
58255+
data-x="attr-script-async">async</code>, <code data-x="attr-script-defer">defer</code>, <code
58256+
data-x="attr-script-crossorigin">crossorigin</code>, and
58257+
<code data-x="attr-script-nonce">nonce</code> attributes dynamically has no direct effect; these
58258+
attributes are only used at specific times described below.</p> <!-- by implication, changes
5822858259
to the base URL also have no effect -->
5822958260

5823058261
<div w-nodev>
@@ -58897,7 +58928,11 @@ dictionary <dfn>RelatedEventInit</dfn> : <span>EventInit</span> {
5889758928

5889858929
</ol>
5889958930

58900-
<p>The IDL attributes <dfn><code data-x="dom-script-src">src</code></dfn>, <dfn><code data-x="dom-script-type">type</code></dfn>, <dfn><code data-x="dom-script-charset">charset</code></dfn>, <dfn><code data-x="dom-script-defer">defer</code></dfn>, each must <span>reflect</span> the respective
58931+
<p>The IDL attributes <dfn><code data-x="dom-script-src">src</code></dfn>, <dfn><code
58932+
data-x="dom-script-type">type</code></dfn>, <dfn><code
58933+
data-x="dom-script-charset">charset</code></dfn>, <dfn><code
58934+
data-x="dom-script-defer">defer</code></dfn>, and <dfn><code
58935+
data-x="dom-script-nonce">nonce</code></dfn>, must each <span>reflect</span> the respective
5890158936
content attributes of the same name.</p>
5890258937

5890358938
<p>The <dfn><code data-x="dom-script-crossOrigin">crossOrigin</code></dfn> IDL attribute must
@@ -112712,7 +112747,8 @@ if (s = prompt('What is your name?')) {
112712112747
<code data-x="attr-script-charset">charset</code>;
112713112748
<code data-x="attr-script-async">async</code>;
112714112749
<code data-x="attr-script-defer">defer</code>;
112715-
<code data-x="attr-script-crossorigin">crossorigin</code></td>
112750+
<code data-x="attr-script-crossorigin">crossorigin</code>;
112751+
<code data-x="attr-script-nonce">nonce</code></td>
112716112752
<td><code>HTMLScriptElement</code></td>
112717112753
</tr>
112718112754

@@ -112813,6 +112849,7 @@ if (s = prompt('What is your name?')) {
112813112849
<td>varies*</td>
112814112850
<td><span data-x="global attributes">globals</span>;
112815112851
<code data-x="attr-style-media">media</code>;
112852+
<code data-x="attr-style-nonce">nonce</code>;
112816112853
<code data-x="attr-style-type">type</code>;
112817112854
<code data-x="attr-style-scoped">scoped</code></td>
112818112855
<td><code>HTMLStyleElement</code></td>
@@ -114128,6 +114165,12 @@ if (s = prompt('What is your name?')) {
114128114165
<td> <code data-x="attr-param-name">param</code>
114129114166
<td> Name of parameter
114130114167
<td> <a href="#attribute-text">Text</a>
114168+
<tr>
114169+
<th> <code data-x="">nonce</code>
114170+
<td> <code data-x="attr-script-nonce">script</code>;
114171+
<code data-x="attr-style-nonce">style</code>
114172+
<td> Cryptographic nonce used in <code>Content Security Policy</code> checks <ref spec="CSP">
114173+
<td> <a href="#attribute-text">Text</a>
114131114174
<tr>
114132114175
<th> <code data-x="">novalidate</code>
114133114176
<td> <code data-x="attr-fs-novalidate">form</code>
@@ -115969,7 +116012,7 @@ INSERT INTERFACES HERE
115969116012
<dd>(Non-normative) <cite><a href="http://www.iana.org/assignments/charset-reg/CP50220">CP50220</a></cite>, Y. Naruse. IANA.</dd> <!-- really should be "NARUSE, Y." or some such, but there's a western bias to these references for consistency. sorry. -->
115970116013

115971116014
<dt id="refsCSP">[CSP]</dt>
115972-
<dd>(Non-normative) <cite><a href="https://w3c.github.io/webappsec/specs/content-security-policy/">Content Security Policy</a></cite>, B. Sterne, A. Barth. W3C.</dd>
116015+
<dd><cite><a href="https://w3c.github.io/webappsec/specs/content-security-policy/">Content Security Policy</a></cite>, M. West, A. Barth, D. Veditz. W3C.</dd>
115973116016

115974116017
<dt id="refsCSS">[CSS]</dt>
115975116018
<dd><cite><a href="https://drafts.csswg.org/css2/">Cascading Style Sheets Level 2 Revision 2</a></cite>, B. Bos, T. &Ccedil;elik, I. Hickson, H. Lie. W3C.</dd>

0 commit comments

Comments
 (0)