[wp-trac] [WordPress Trac] #46471: Malformed content when using the More block and stripping the teaser

WordPress Trac noreply at wordpress.org
Mon Apr 1 11:01:33 UTC 2019


#46471: Malformed content when using the More block and stripping the teaser
-------------------------------------+---------------------
 Reporter:  lukecarbis               |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  5.2
Component:  General                  |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+---------------------

Comment (by birgire):

 As mentioned, the content can be dived through {{{<!--more(.*?)?-->}}}
 regardless of any More block wrappers around it, leaving unclosed More
 block tags in each part.

 I guess one could enhance that splitting with {{{preg_split()}}} but I
 think that would not be as clean and simple as in
 [attachment:"46471.1.diff"].

 Currently [attachment:"46471.1.diff"] runs the {{{preg_replacement}}},
 regardless if there are any blocks in the content or not. The
 {{{has_block( 'more', $content )}}} (passing content to avoid
 {{{get_post}}}) comes to mind or a simple {{{strpos}}} check. I would
 expect the {{{strpos}}} vs {{{preg_replace}}} performance would only show
 up for very large content and multiple calls.

 Maybe this More block content check is not needed as I can imagine more
 and more content will contain blocks.

 ----

 We can also see this with {{{the_content()}}} when using the noteaser text
 tag.

 Example:

 {{{
 <!-- wp:paragraph -->
 <p>Teaser part.</p>
 <!-- /wp:paragraph -->

 <!-- wp:more -->
 <!--more-->
 <!--noteaser-->
 <!-- /wp:more -->

 <!-- wp:paragraph -->
 <p>Second block.</p>
 <!-- /wp:paragraph -->

 }}}

 The patch in [attachment:"46471-2.diff"] is a first iteration of tests for
 [attachment:"46471.1.diff"].

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46471#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list