postcss-functions icon indicating copy to clipboard operation
postcss-functions copied to clipboard

Lax argument validation cause crash with some at-rules

Open rubycon opened this issue 4 years ago • 0 comments

When processing at-rules, postcss-functions expect the node to have a "params" entry but not all at-rules have params. So node.params can be undefined and cause an error when passed to postcss-value-parser.

https://github.com/andyjansson/postcss-functions/blob/d834e0a5db89b9e8ee4dbc873aabedb744c6ab98/src/lib/transformer.mjs#L65-L69

The transformString() function should check if a proper string is supplied and fallback to an empty string or avoid parsing if not.

I never had any troubles with PostCSS and font-face rules before. I only notice this bug after a recent update. Apparently my occurrence of the bug is triggered by postcss-font-magician which inject its own at-rules with no params entry (which is not a bug).

rubycon avatar Jun 30 '21 13:06 rubycon