Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#32755 closed defect (bug) (fixed)

media_sideload_image should return early when preg_match didn't match

Reported by: serpent7776 Owned by: chriscct7
Priority: normal Milestone: 4.4
Component: Upload Version: 4.2.2
Severity: normal Keywords: has-patch commit
Cc: Focuses:

Description

If media_sideload_image function is given an url that does not match pattern

'/[^\?]+\.(jpe?g|jpe|gif|png)\b/i'

it should return with error instead of carrying on, because it raises a notice

Notice: Undefined offset: 0 in <path>/wordpress/wp-admin/includes/media.php on line 840

basicaly it tries to access

basename( $matches[0] )

but $matches is empty

Attachments (1)

32755.diff​ (606 bytes ) - added by MikeHansenMe 11 years ago.

Download all attachments as: .zip

Change History (5)

@MikeHansenMe
11 years ago

#1 @MikeHansenMe
11 years ago

  • Keywords has-patch added

#2 @chriscct7
11 years ago

  • Keywords commit added
  • Milestone Awaiting Review → 4.4
  • Owner set to chriscct7
  • Status new → assigned

#3 @chriscct7
11 years ago

  • Type enhancement → defect (bug)

#4 @SergeyBiryukov
11 years ago

  • Resolution → fixed
  • Status assigned → closed

In 34984:

Media: Return early from media_sideload_image() if $file didn't match the pattern for images.

Props MikeHansenMe, serpent7776.
Fixes #32755.

Note: See TracTickets for help on using tickets.