Opened 7 years ago
Closed 7 years ago
#46597 closed defect (bug) (fixed)
Grid properties stripped from style attribute after saving post
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 5.2 | Priority: | normal |
| Severity: | normal | Version: | 5.0 |
| Component: | Editor | Keywords: | has-patch commit |
| Focuses: | Cc: |
Description
When resizing a Media and Text block, something like style="grid-template-columns:9% auto" is added to the rendered markup. If you're not admin (don't have unfiltered_html?), this is stripped by saving (in safecss_filter_attr, I think), which then causes the block to not match and appear "invalid".
This can also be reproduced with plain content, using the HTML block:
- Use an "author" level user
- Add an HTML block
- Add the content
<div style="grid-template-columns:9% auto">Testing</div> - Save the post and reload the page
- The style attribute has been stripped
Attachments (1)
Change History (10)
This ticket was mentioned in Slack in #core-editor by peterwilsoncc. View the logs.
7 years ago
#4
@
7 years ago
At a minimum, I'd expect the safecss_filter_attr to include those style properties produced by blocks shipped with core. To this end, I've audited the save implementations of existing blocks, and discovered the following properties:
background-color(button, cover, paragraph, pullquote)background-image(cover)background-position(cover)border-color(pullquote)color(button, paragraph, pullquote)font-size(paragraph)grid-template-columns(media-text)height(spacer)max-width(image)text-align(heading, paragraph, quote, subhead, verse)width(image)
Cross-referenced against the default `safe_style_css` set, here's what's missing:
background-positiongrid-template-columns
This ticket was mentioned in Slack in #core-editor by aduth. View the logs.
7 years ago
#6
@
7 years ago
- Component changed from General to Editor
- Keywords has-patch commit added
- Version set to 5.0
The patch applies cleanly to trunk and appears to fix the issue of background-position and grid-template-columns being removed for users with the Author role.
I can reproduce this, via author user role, for:
I also noticed the same removal of
display: grid;.Out of curiosity I had a look at possible other grid CSS properties and here's the list so far:
I might have missed some?
These are unsupported in
safecss_filter_attr().Useful References:
https://www.w3.org/TR/css-grid-1/
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
https://css-tricks.com/snippets/css/complete-guide-grid/