diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php
index b5b30acead880..9e18b04c176da 100644
--- a/src/wp-includes/embed.php
+++ b/src/wp-includes/embed.php
@@ -931,6 +931,7 @@ function wp_filter_oembed_result( $result, $data, $url ) {
'a' => array(
'href' => true,
),
+ 'p' => array(),
'blockquote' => array(),
'iframe' => array(
'src' => true,
@@ -947,36 +948,36 @@ function wp_filter_oembed_result( $result, $data, $url ) {
$html = wp_kses( $result, $allowed_html );
preg_match( '|(
.*?
)?.*()|ms', $html, $content );
+
// We require at least the iframe to exist.
- if ( empty( $content[2] ) ) {
- return false;
- }
- $html = $content[1] . $content[2];
+ if ( ! empty( $content[2] ) ) {
+ $html = $content[1] . $content[2];
- preg_match( '/ src=([\'"])(.*?)\1/', $html, $results );
+ preg_match( '/ src=([\'"])(.*?)\1/', $html, $results );
- if ( ! empty( $results ) ) {
- $secret = wp_generate_password( 10, false );
+ if ( ! empty( $results ) ) {
+ $secret = wp_generate_password( 10, false );
- $url = esc_url( "{$results[2]}#?secret=$secret" );
- $q = $results[1];
+ $url = esc_url( "{$results[2]}#?secret=$secret" );
+ $q = $results[1];
- $html = str_replace( $results[0], ' src=' . $q . $url . $q . ' data-secret=' . $q . $secret . $q, $html );
- $html = str_replace( 'HelloWorld
';
$actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' );
- $this->assertFalse( $actual );
+ $this->assertSame( 'HelloWorld
' ,$actual );
$html = '';
$actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' );
- $this->assertFalse( $actual );
+ $this->assertSame( '' , $actual );
}
public function test_filter_oembed_result_secret_param_available() {
@@ -76,7 +76,7 @@ public function test_filter_oembed_result_wrong_type_provided() {
public function test_filter_oembed_result_invalid_result() {
$this->assertFalse( wp_filter_oembed_result( false, (object) array( 'type' => 'rich' ), '' ) );
- $this->assertFalse( wp_filter_oembed_result( '', (object) array( 'type' => 'rich' ), '' ) );
+ $this->assertSame( '', wp_filter_oembed_result( '', (object) array( 'type' => 'rich' ), '' ) );
}
public function test_filter_oembed_result_blockquote_adds_style_to_iframe() {
@@ -136,4 +136,34 @@ public function test_filter_feed_content() {
$this->assertSame( '', $actual );
}
+
+ /**
+ * Test standalone blockquote with paragraph tag is allowed.
+ */
+ public function test_filter_oembed_result_standalone_blockquote_paragraph() {
+ $html = 'Test content
';
+ $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' );
+
+ $this->assertSame( 'Test content
', $actual );
+ }
+
+ /**
+ * Test multiple paragraph tags within blockquote are preserved.
+ */
+ public function test_filter_oembed_result_multiple_paragraphs() {
+ $html = 'First paragraph
Second paragraph
';
+ $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' );
+
+ $this->assertSame( 'First paragraph
Second paragraph
', $actual );
+ }
+
+ /**
+ * Test blockquote with paragraph and link tags.
+ */
+ public function test_filter_oembed_result_paragraph_with_link() {
+ $html = 'Text with link
';
+ $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' );
+
+ $this->assertSame( 'Text with link
', $actual );
+ }
}