Make WordPress Core


Ignore:
Timestamp:
11/13/2021 07:26:52 AM (4 years ago)
Author:
westonruter
Message:

Embeds: Fix parsing of post embeds in wp_filter_oembed_result() by appending wp-embed script instead of prepending it in get_post_embed_html().

Due to the way that the blockquote and iframe are being parsed with a regular expression in wp_filter_oembed_result(), if there is any content at all before the blockquote start tag then it will fail to be included in the first matching group. By appending the wp-embed script instead of prepending it in get_post_embed_html(), then the parsing issue is avoided.

Also use non-greedy match wp_maybe_enqueue_oembed_host_js().

Amends [52132].
Fixes #44632.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/oembed/template.php

    r52132 r52153  
    301301        $actual   = preg_replace( '/secret=("?)\w+\1/', 'secret=__SECRET__', $actual );
    302302
    303         $this->assertStringEndsWith( $expected, $actual );
     303        $this->assertStringStartsWith( '<blockquote class="wp-embedded-content" data-secret=__SECRET__>', $actual );
     304        $this->assertStringContainsString( $expected, $actual );
     305        $this->assertStringEndsWith( '</script>', trim( $actual ) );
    304306    }
    305307
Note: See TracChangeset for help on using the changeset viewer.