Make WordPress Core

Opened 14 years ago

Closed 12 years ago

#16693 closed defect (bug) (fixed)

media_sideload_image() fails on jpeg names

Reported by: numediaweb's profile numediaweb Owned by: markjaquith's profile markjaquith
Milestone: 3.5 Priority: normal
Severity: major Version: 3.1
Component: General Keywords: has-patch 3.2-early commit
Focuses: Cc:

Description

if you give an image file name with jpeg as extension, media_sideload_image() returns .jpe file name extension.

the problem is in the function at file: wp-admin/includes/media.php,line 565

preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', 'test.jpeg', $matches);
echo basename($matches[0]); // returns : test.jpe

this bugs image uploading process; it doesn't allow post thumbnail generation.

Attachments (5)

16693.diff (2.1 KB) - added by nacin 14 years ago.
16693.2.diff (537 bytes) - added by sivel 14 years ago.
Little variation on the patch
16693.3.diff (1.7 KB) - added by nacin 14 years ago.
16693.4.diff (1.8 KB) - added by sivel 14 years ago.
16693.5.diff (1.7 KB) - added by georgestephanis 12 years ago.
Updated to current trunk to accomodate for line numbers and such

Download all attachments as: .zip

Change History (12)

#1 @nacin
14 years ago

Sounds like the ordering could be better. Try this for the regular expression instead:

/[^\?]+\.(jpg|jpeg|jpe|gif|png)/i

#2 @numediaweb
14 years ago

Thanx ncin,
I copied the same function from media.php to my custom functions and added a prefix to its name, then, just deleted the jpe|JPE|

waiting for the official fix in the next release.

@nacin
14 years ago

@sivel
14 years ago

Little variation on the patch

#3 @sivel
14 years ago

  • Keywords has-patch added

Small variation on the patch.

@nacin
14 years ago

#4 @nacin
14 years ago

  • Keywords 3.2-early added
  • Milestone changed from Awaiting Review to Future Release

sivel's patch looks good. I also went through other instances and made us a bit more consistent in select places.

@sivel
14 years ago

#5 @sivel
14 years ago

Updated the patch to the stepping-on-toes edition (16693.4.diff)

@georgestephanis
12 years ago

Updated to current trunk to accomodate for line numbers and such

#6 @nacin
12 years ago

  • Keywords commit added
  • Milestone changed from Future Release to 3.5

#7 @markjaquith
12 years ago

  • Owner set to markjaquith
  • Resolution set to fixed
  • Status changed from new to closed

In [21219]:

Better image extension regexes, so we don't just grab the "jpe" from "jpeg" files in media_sideload_image(). props sivel. fixes #16693

Note: See TracTickets for help on using tickets.