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.
Built from https://develop.svn.wordpress.org/trunk@48983


git-svn-id: http://core.svn.wordpress.org/trunk@48745 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-09-17 10:14:07 +00:00
parent 75262781d9
commit ac00862f44
2 changed files with 2 additions and 2 deletions

View File

@ -5243,7 +5243,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)((\s[^>]*)?)>!i", '_links_add_target', $content );
}
/**

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6-alpha-48982';
$wp_version = '5.6-alpha-48983';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.