Editor: Ensure block comments are of a valid form.
Ensures that the block delimiter comments are of a valid form: opening with `<!--` and closing with `-->`. Props xknown, isabel_brison, peterwilsoncc. Merges [55762] to branch 6.2. Built from https://develop.svn.wordpress.org/branches/6.2@55767 git-svn-id: http://core.svn.wordpress.org/branches/6.2@55279 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2edd1a7d5c
commit
fc13f95a4d
|
@ -798,6 +798,10 @@ function serialize_blocks( $blocks ) {
|
|||
function filter_block_content( $text, $allowed_html = 'post', $allowed_protocols = array() ) {
|
||||
$result = '';
|
||||
|
||||
if ( false !== strpos( $text, '<!--' ) && false !== strpos( $text, '--->' ) ) {
|
||||
$text = preg_replace_callback( '%<!--(.*?)--->%', '_filter_block_content_callback', $text );
|
||||
}
|
||||
|
||||
$blocks = parse_blocks( $text );
|
||||
foreach ( $blocks as $block ) {
|
||||
$block = filter_block_kses( $block, $allowed_html, $allowed_protocols );
|
||||
|
@ -807,6 +811,19 @@ function filter_block_content( $text, $allowed_html = 'post', $allowed_protocols
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback used for regular expression replacement in filter_block_content().
|
||||
*
|
||||
* @private
|
||||
* @since 6.2.1
|
||||
*
|
||||
* @param array $matches Array of preg_replace_callback matches.
|
||||
* @return string Replacement string.
|
||||
*/
|
||||
function _filter_block_content_callback( $matches ) {
|
||||
return '<!--' . rtrim( $matches[1], '-' ) . '-->';
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters and sanitizes a parsed block to remove non-allowable HTML
|
||||
* from block attribute values.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.2.1-RC1-55766';
|
||||
$wp_version = '6.2.1-RC1-55767';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue