Pings/Trackbacks: Avoid a PHP notice in do_enclose()
when encountering a URL without a path in post content.
Props jbouganim, mukesh27, Otto42, SergeyBiryukov. Fixes #49872. git-svn-id: https://develop.svn.wordpress.org/trunk@48621 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5006831979
commit
6fa3286a1b
@ -907,7 +907,7 @@ function do_enclose( $content = null, $post ) {
|
||||
|
||||
// Check to see if we can figure out the mime type from the extension.
|
||||
$url_parts = parse_url( $url );
|
||||
if ( false !== $url_parts ) {
|
||||
if ( false !== $url_parts && ! empty( $url_parts['path'] ) ) {
|
||||
$extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
|
||||
if ( ! empty( $extension ) ) {
|
||||
foreach ( wp_get_mime_types() as $exts => $mime ) {
|
||||
|
@ -135,6 +135,10 @@ class Tests_Functions_DoEnclose extends WP_UnitTestCase {
|
||||
'expected' => "https://example.com/wp-content/uploads/2018/06/audio.ogg\n321\naudio/ogg\n" .
|
||||
"https://example.com/wp-content/uploads/2018/06/movie.mp4\n123\nvideo/mp4\n",
|
||||
),
|
||||
'no-path' => array(
|
||||
'content' => 'https://example.com?test=1',
|
||||
'expected' => '',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user