diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 7f69321a71..72fcb4e554 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -5978,16 +5978,20 @@ function wp_unslash( $value ) { * * @since 3.6.0 * - * @param string $content A string which might contain a URL. - * @return string|false The found URL. + * @param string $content A string which might contain an `A` element with a non-empty `href` attribute. + * @return string|false Database-escaped URL via {@see esc_url()} if found, otherwise `false`. */ function get_url_in_content( $content ) { if ( empty( $content ) ) { return false; } - if ( preg_match( '/]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) { - return sanitize_url( $matches[2] ); + $processor = new WP_HTML_Tag_Processor( $content ); + while ( $processor->next_tag( 'A' ) ) { + $href = $processor->get_attribute( 'href' ); + if ( is_string( $href ) && ! empty( $href ) ) { + return sanitize_url( $href ); + } } return false; diff --git a/wp-includes/version.php b/wp-includes/version.php index 7a0ae041ff..332a838908 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.9-alpha-60664'; +$wp_version = '6.9-alpha-60665'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.