From dc01b08a5e42f0487b669042b9a9b60ceb252cde Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 22 Nov 2013 16:25:10 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@26328 git-svn-id: http://core.svn.wordpress.org/trunk@26230 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 56aac4ca29..4aa2cd3183 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -3243,7 +3243,7 @@ function links_add_target( $content, $target = '_blank', $tags = array('a') ) { global $_links_add_target; $_links_add_target = $target; $tags = implode('|', (array)$tags); - return preg_replace_callback( "!<($tags)(.+?)>!i", '_links_add_target', $content ); + return preg_replace_callback( "!<($tags)([^>]*)>!i", '_links_add_target', $content ); } /** @@ -3258,7 +3258,7 @@ function links_add_target( $content, $target = '_blank', $tags = array('a') ) { function _links_add_target( $m ) { global $_links_add_target; $tag = $m[1]; - $link = preg_replace('|(target=([\'"])(.*?)\2)|i', '', $m[2]); + $link = preg_replace('|( target=([\'"])(.*?)\2)|i', '', $m[2]); return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">'; }