icon-block icon indicating copy to clipboard operation
icon-block copied to clipboard

This block contains unexpected or invalid content.

Open vibrains opened this issue 1 year ago • 7 comments

Hi, I keep running into this issue: Screenshot 2023-09-15 at 10 42 15 AM

When I resolve the block it looks like the invalid content is just empty spaces: Screenshot 2023-09-15 at 10 41 59 AM

vibrains avatar Sep 15 '23 14:09 vibrains

Hi @vibrains, can you share what version of WordPress and/or Gutenberg you are running? Thanks

ndiego avatar Sep 15 '23 15:09 ndiego

@ndiego WordPress version: 6.3.1

vibrains avatar Sep 15 '23 16:09 vibrains

Hmm interesting. I am not able to replicate this. Is there anything else you can share about your setup?

ndiego avatar Sep 15 '23 21:09 ndiego

Hi, it's showing me this error. I have used Insert custom SVG, then paste any svg code, then Insert custom icon, then click on replace and clear icon and again click to Insert custom SVG then it shows this error. I'm using WP 6.3.1, Frost Theme and no plugin.

IMG_0361

cotusandro avatar Sep 18 '23 17:09 cotusandro

Getting the same issue. Can only assume it is to do with character encoding, or similar... We're running on WPVIP, WP 6.3.2, PHP 8.0.

Screenshot 2023-10-19 at 11 10 02

TheoEnnismore avatar Oct 19 '23 11:10 TheoEnnismore

FYI: it appears to be related to user capabilities when running a multisite - so in our case, a super admin was the only role that was able to add the icon blocks successfully; even an administrator encountered the same issue. https://wordpress.org/plugins/unfiltered-mu/ - adding this plugin fixes the issue.

TheoEnnismore avatar Oct 26 '23 09:10 TheoEnnismore

Thanks @TheoEnnismore for pointing us in the right direction! It's definitely because the inline SVG is being sanitized without the unfiltered_html capability. On MS, that's removed for pretty much everyone. On a single site, only editors and admins will have this capability. So an author, for example, could add an icon but then be surprised when it never displays.

I think it would be better to not encourage enabling unfiltered_html widely.

@ndiego I wonder if a possible solution might be to only store the reference to the SVG in the block's content, rather than the SVG itself. Then load the SVG into the editor when the editor is loaded, and add it to page views in the backend through PHP.

Two problems I see with that, though:

  1. Since the SVG isn't stored in post_content, if the plugin is disabled in the future the SVGs will be lost
  2. If the block's icon library is changed and an icon is removed, it will also be lost.

But maybe those are reasonable given the risk of folks disabling unfiltered_html.

jessedyck avatar Aug 19 '24 17:08 jessedyck