WordPress.org

Make WordPress Core

Ticket #46402: 46402.diff

File 46402.diff, 1.5 KB (added by birgire, 9 months ago)
  • src/wp-includes/formatting.php

    diff --git src/wp-includes/formatting.php src/wp-includes/formatting.php
    index e690948..1727c72 100644
    function wp_rel_nofollow_callback( $matches ) { 
    30403040function wp_targeted_link_rel( $text ) {
    30413041        // Don't run (more expensive) regex if no links with targets.
    30423042        if ( stripos( $text, 'target' ) !== false && stripos( $text, '<a ' ) !== false ) {
    3043                 $text = preg_replace_callback( '|<a\s([^>]*target\s*=[^>]*)>|i', 'wp_targeted_link_rel_callback', $text );
     3043                if ( ! is_serialized( $text ) ) {
     3044                        $text = preg_replace_callback( '|<a\s([^>]*target\s*=[^>]*)>|i', 'wp_targeted_link_rel_callback', $text );
     3045                }
    30443046        }
    30453047
    30463048        return $text;
  • tests/phpunit/tests/formatting/WPTargetedLinkRel.php

    diff --git tests/phpunit/tests/formatting/WPTargetedLinkRel.php tests/phpunit/tests/formatting/WPTargetedLinkRel.php
    index 08f8ac1..929c04f 100644
    class Tests_Targeted_Link_Rel extends WP_UnitTestCase { 
    101101
    102102                $this->assertEquals( $expected, $post->post_content );
    103103        }
     104
     105        /**
     106         * Ensure entirely serialized content is ignored.
     107         *
     108         * @ticket 46402.
     109         */
     110        public function test_ignore_entirely_serialized_content() {
     111                $content  = 'a:1:{s:4:"html";s:52:"<p>Links: <a href="/" target="_blank">No Rel</a></p>";}';
     112                $expected = 'a:1:{s:4:"html";s:52:"<p>Links: <a href="/" target="_blank">No Rel</a></p>";}';
     113                $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );
     114        }
     115
    104116}