Make WordPress Core

Changeset 45408


Ignore:
Timestamp:
05/25/2019 12:04:28 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Formatting: Don't run wp_targeted_link_rel() on entirely serialized content.

Props birgire, elliotcondon.
Fixes #46402.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r45348 r45408  
    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
  • trunk/tests/phpunit/tests/formatting/WPTargetedLinkRel.php

    r45348 r45408  
    128128        $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );
    129129    }
     130
     131    /**
     132     * Ensure entirely serialized content is ignored.
     133     *
     134     * @ticket 46402.
     135     */
     136    public function test_ignore_entirely_serialized_content() {
     137        $content  = 'a:1:{s:4:"html";s:52:"<p>Links: <a href="/" target="_blank">No Rel</a></p>";}';
     138        $expected = 'a:1:{s:4:"html";s:52:"<p>Links: <a href="/" target="_blank">No Rel</a></p>";}';
     139        $this->assertEquals( $expected, wp_targeted_link_rel( $content ) );
     140    }
     141
    130142}
Note: See TracChangeset for help on using the changeset viewer.