WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.42k stars 4.17k forks source link

When the user role is author, blocks cannot be edited if the block name contains consecutive hyphens (unsupported). #36339

Open inc2734 opened 2 years ago

inc2734 commented 2 years ago

Description

When the user role is author, blocks cannot be edited if the block name contains consecutive hyphens (unsupported). I want it to appear the same way in all roles.

I couldn't decide if such naming conventions were not allowed or if it was a bug, so I raised an issue.

Step-by-step reproduction instructions

  1. Create a custom block with a block name that includes consecutive hyphens. (e.g. snow-monkey-blocks/accordion--item)
  2. Insert this block and save the post.
  3. Reload the edit screen.
  4. The block is no longer editable. "Your site doesn't include support for the xxx"
  5. In this case, the block name displayed in the core/missing block is abbreviated to a single hyphen. (e.g. snow-monkey-blocks/accordion-item)

When editor and administrator, This does not occur.

Screenshots, screen recording, code snippet

スクリーンショット 2021-11-09 15 57 29

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

skorasaurus commented 2 years ago

I'm able to reproduce this in Gutenberg 12.3.0

I created a test block at https://gitlab.com/cpl/test-case--36339 it was made from create-block.

Console error returns the following:

Specifically appears rest_block_directory_cannot_view

XHR GET https://mysite.test/wp-json/wp/v2/block-directory/search?term=block:create-block/test-case-36339&_locale=user
[HTTP/2 403 Forbidden 600ms]

1

{"code":"rest_block_directory_cannot_view","message":"Sorry, you are not allowed to browse the block directory.","data":{"status":403}}
mauriac commented 2 years ago

Hello @inc2734 thanks for the report, I'm able to reproduce the bug thanks to @skorasaurus plugin. I found that the error is due to users with "Editor" role has not _unfilteredhtml capability that means the post content will be filtered and striped by using _wp_kses_ (WordPress core function). And there is the problem _wpkses transform the block comment... I don't really know how to fix it in Gutenberg, but what I can suggest right now is to use a third party plugin to add _unfilteredhtml capability to Editor .

If you have any other thoughts, please share them.

Regards.

mauriac commented 2 years ago

Console error returns the following:

Specifically appears rest_block_directory_cannot_view

XHR GET https://mysite.test/wp-json/wp/v2/block-directory/search?term=block:create-block/test-case-36339&_locale=user
[HTTP/2 403 Forbidden 600ms]

1

{"code":"rest_block_directory_cannot_view","message":"Sorry, you are not allowed to browse the block directory.","data":{"status":403}}

This one is appear even when your plugin is disable. It's appear for user with role Editor so I don't think it is related to the main issue here, may be it's worth another issue. I don't find the cause though.

JeremieLevain commented 1 year ago

Hello @mauriac ! Do you think it is possible to adapt "wp_kses" to not filter the name of the blocks? Or to let the use of several hyphens?