Make WordPress Core

Changeset 48621


Ignore:
Timestamp:
07/26/2020 02:06:03 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r48607 r48621  
    908908                // Check to see if we can figure out the mime type from the extension.
    909909                $url_parts = parse_url( $url );
    910                 if ( false !== $url_parts ) {
     910                if ( false !== $url_parts && ! empty( $url_parts['path'] ) ) {
    911911                    $extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
    912912                    if ( ! empty( $extension ) ) {
  • trunk/tests/phpunit/tests/functions/doEnclose.php

    r46644 r48621  
    136136                                "https://example.com/wp-content/uploads/2018/06/movie.mp4\n123\nvideo/mp4\n",
    137137            ),
     138            'no-path'               => array(
     139                'content'  => 'https://example.com?test=1',
     140                'expected' => '',
     141            ),
    138142        );
    139143    }
Note: See TracChangeset for help on using the changeset viewer.