Make WordPress Core


Ignore:
Timestamp:
09/17/2020 10:12:32 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Formatting: Make sure links_add_target() adds the target attribute to the correct tag.

Previously, the attribute could unintentionally be added to a tag that starts with the same characters, e.g. <aside> instead of <a>.

Props antonlukin.
Fixes #51313.

File:
1 edited

Legend:

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

    r48817 r48983  
    52445244    $_links_add_target = $target;
    52455245    $tags              = implode( '|', (array) $tags );
    5246     return preg_replace_callback( "!<($tags)([^>]*)>!i", '_links_add_target', $content );
     5246    return preg_replace_callback( "!<($tags)((\s[^>]*)?)>!i", '_links_add_target', $content );
    52475247}
    52485248
Note: See TracChangeset for help on using the changeset viewer.