From d9b0e70d4ada6fa471f93c6363745522195ab0ef Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 17 Jan 2014 07:47:10 +0000 Subject: [PATCH] Unit tests for get_url_in_content(). Return false when no content is passed, to match the return value of no links being found. props mdbitz. #26171. Built from https://develop.svn.wordpress.org/trunk@26972 git-svn-id: http://core.svn.wordpress.org/trunk@26851 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index c56d82017e..27d64e1dc6 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -3770,11 +3770,13 @@ function wp_unslash( $value ) { * @return string The found URL. */ function get_url_in_content( $content ) { - if ( empty( $content ) ) - return ''; + if ( empty( $content ) ) { + return false; + } - if ( preg_match( '/]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) + if ( preg_match( '/]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) { return esc_url_raw( $matches[2] ); + } return false; }