Make WordPress Core


Ignore:
Timestamp:
11/22/2013 04:24:25 PM (11 years ago)
Author:
wonderboymusic
Message:

Add unit tests for links_add_target(). Alter the patterns in links_add_target() and _links_add_target() slightly based on learnings after running tests.

Props mdbitz.
Fixes #26164.

File:
1 edited

Legend:

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

    r26191 r26328  
    32443244    $_links_add_target = $target;
    32453245    $tags = implode('|', (array)$tags);
    3246     return preg_replace_callback( "!<($tags)(.+?)>!i", '_links_add_target', $content );
     3246    return preg_replace_callback( "!<($tags)([^>]*)>!i", '_links_add_target', $content );
    32473247}
    32483248
     
    32593259    global $_links_add_target;
    32603260    $tag = $m[1];
    3261     $link = preg_replace('|(target=([\'"])(.*?)\2)|i', '', $m[2]);
     3261    $link = preg_replace('|( target=([\'"])(.*?)\2)|i', '', $m[2]);
    32623262    return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">';
    32633263}
Note: See TracChangeset for help on using the changeset viewer.