Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#49944 closed enhancement (duplicate)

media_sideload_image() fails with no file extension.

Reported by: secondlinethemes's profile secondlinethemes Owned by:
Milestone: Priority: normal
Severity: minor Version: 5.4
Component: Media Keywords: needs-patch
Focuses: Cc:


The media_sideload_image() function is only able to use paths with full file extensions (i.e - However, if a valid image is based in a URL with no extension, it fails. (i.e. -

The extension-less URL can still have a valid image content-type header for the image. It fails twice, both in the regex test -
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );

And in the media_handle_sideload function, both times due to a "naked" filename.

Some popular CDN platforms are serving media files this way. (I've also seen some serve files with a query right before the extension, i.e - https://example/com/img/image?.jpg - this also fails because of the regex.

Change History (2)

#1 @SergeyBiryukov
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome to WordPress Trac!

Thank for the report, we're already tracking this issue in #18730.

#2 @secondlinethemes
4 years ago

Thanks @SergeyBiryukov, and sorry for the dupe!

Note: See TracTickets for help on using tickets.