Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sanitization for style-engine declarations #42968

Closed
wants to merge 3 commits into from
Closed

Conversation

aristath
Copy link
Member

@aristath aristath commented Aug 4, 2022

What?

Fixes #42948

This PR is a partial from #42893, specifically the part of that PR regarding the sanitization of CSS delcarations in the style engine.

Why?

Some things need to bypass the safecss_filter_attr call, and the sanitization of values is further improved here.

Comment on lines 133 to 143
if (
0 === strpos( $property, '--' ) || // Account for CSS variables.
( 'display' === $property && 'none' !== $value ) || // Account for "display" when the value is not "none".
0 === strpos( $value, 'min(' ) || // Account for min() values.
0 === strpos( $value, 'max(' ) || // Account for max() values.
0 === strpos( $value, 'clamp(' ) // Account for clamp() values.
) {
$declarations_output .= "{$indent}{$property}:{$spacer}{$value};$suffix";
continue;
}
$filtered_declaration = safecss_filter_attr( "{$property}:{$spacer}{$value};" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can use safecss_filter_attr_allow_css filter and regex from 55966. Then we can remove the compat function after the core patch is merged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's a good point. Ideally we'd be deferring as much as possible to safecss_filter_attr rather than adding too much extra handling in the style engine directly.

I've opened up a potential alternative PR in #43004 to play with this idea.

@andrewserong
Copy link
Contributor

Thanks for picking this one up @aristath and digging in! I think @Mamaduka raises a good point about seeing if we can use the proposed update in core filtering to hopefully sidetrack having to include too much logic directly in the style engine for the additional CSS functions. I've had a go at this in #43004 as a potential alternative.

@aristath
Copy link
Member Author

aristath commented Aug 9, 2022

no longer needed after #43004 was merged, closing.

@aristath aristath closed this Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🗄 Closed / not merged
Development

Successfully merging this pull request may close these issues.

1.3.9: clamp() is no longer recognized in “contentSize” or “wideSize” in theme.json
4 participants