-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
When the content is filtered with the_content filter, the replaced content is truncated because it's not wrapped in the post-content block.
Screenshots of the issue
On Five for the Future we inject the company description:
In "notice" blocks, we run the_content to parse markup:
To reproduce
- Add the following to your site, which will replace all content with
123456789add_filter( 'the_content', function() { return '123456789'; }, 1 ); - View any page, and you'll only see
456.
More details
This is due to #67272 adding add_filter( 'the_content', 'remove_serialized_parent_block', 8 );, and remove_serialized_parent_block does not check for serialized blocks before running substr. This results in it trimming from 3, -3 if there is no wrapper.
Additionally, any blocks that run the_content on attributes are also truncated, as this filter runs in the course of rendering the block.
I'm not sure if the better solution is to add a check in remove_serialized_parent_block, or to change how the filter is applied in core/post-content, but I'm happy to draft a core patch if needed.