From 94e4020506095de332d36eda6d1774622630e323 Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Tue, 11 Jun 2024 17:31:19 +0200 Subject: [PATCH] Fix regex --- lib/compat/wordpress-6.5/blocks.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/compat/wordpress-6.5/blocks.php b/lib/compat/wordpress-6.5/blocks.php index a151bcbedb6fae..8aae938597a12f 100644 --- a/lib/compat/wordpress-6.5/blocks.php +++ b/lib/compat/wordpress-6.5/blocks.php @@ -125,7 +125,13 @@ function gutenberg_block_bindings_replace_html( $block_content, $block_name, str } if ( 'core/image' === $block_name && 'caption' === $attribute_name ) { // TODO: Don't use regex. - return preg_replace( '/(]*>)(.*?)(<\/figcaption>)/i', $amended_content->get_updated_html(), $block_content ); + return preg_replace_callback( + '/]*>.*?<\/figcaption>/is', + function () use ( $amended_content ) { + return $amended_content->get_updated_html(); + }, + $block_content + ); } } else { $block_reader->seek( 'iterate-selectors' );