Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtered post content is truncated in post-content block #68605

Open
ryelle opened this issue Jan 10, 2025 · 0 comments
Open

Filtered post content is truncated in post-content block #68605

ryelle opened this issue Jan 10, 2025 · 0 comments
Labels
[Block] Post Content Affects the Post Content Block [Feature] Block hooks [Type] Bug An existing feature does not function as intended

Comments

@ryelle
Copy link
Contributor

ryelle commented Jan 10, 2025

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:

Image

In "notice" blocks, we run the_content to parse markup:

Image

To reproduce

  • Add the following to your site, which will replace all content with 123456789
     add_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.

@ryelle ryelle added [Block] Post Content Affects the Post Content Block [Feature] Block hooks [Type] Bug An existing feature does not function as intended labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Content Affects the Post Content Block [Feature] Block hooks [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

1 participant