ezyang / htmlpurifier

Standards compliant HTML filter written in PHP
http://htmlpurifier.org
GNU Lesser General Public License v2.1
3.07k stars 327 forks source link

feat: Allow universal CSS values for all properties #410

Closed zerocrates closed 3 months ago

zerocrates commented 3 months ago

Support for the universal or "CSS-wide" property values (initial, inherit, and unset, see https://www.w3.org/TR/css-values/#common-keywords) is mixed at the moment.

Several properties manually are defined to allow initial and inherit, currently:

Separately, inherit is allowed for every property, but only in the style attribute, not in an extracted style block (the code that does this is only in the CSS AttrDef).

This PR removes the special case in AttrDef_CSS and the explicit enum definitions in the CSSDefinition, and replaces both with checks in AttrDef_CSS and Filter_ExtractStyleBlocks against an enum of initial, inherit, and unset, making all three values allowed for all defined properties in both the attribute and block contexts.

unset, which hasn't previously been allowed here, is comparable to initial and inherit: for properties that inherit by default, it acts as inherit, for those that don't, it acts as initial.