ndiego / icon-block

Effortlessly add SVG icons and graphics to your website.
https://nickdiego.com/projects/icon-block/
GNU General Public License v2.0
110 stars 15 forks source link

This block contains unexpected or invalid content. #36

Open vibrains opened 1 year ago

vibrains commented 1 year ago

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

ndiego commented 1 year ago

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

vibrains commented 1 year ago

@ndiego WordPress version: 6.3.1

ndiego commented 1 year ago

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

cotusandro commented 1 year ago

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

TheoEnnismore commented 11 months ago

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 commented 11 months ago

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.

jessedyck commented 1 month ago

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.