Make WordPress Core

Opened 16 years ago

Closed 14 years ago

#16693 closed defect (bug) (fixed)

media_sideload_image() fails on jpeg names

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

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 16 years ago.
16693.2.diff (537 bytes ) - added by sivel 16 years ago.
Little variation on the patch
16693.3.diff (1.7 KB ) - added by nacin 16 years ago.
16693.4.diff (1.8 KB ) - added by sivel 16 years ago.
16693.5.diff (1.7 KB ) - added by georgestephanis 14 years ago.
Updated to current trunk to accomodate for line numbers and such

Download all attachments as: .zip

Change History (12)

#1 @nacin
16 years ago

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

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

#2 @numediaweb
16 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
16 years ago

@sivel
16 years ago

Little variation on the patch

#3 @sivel
16 years ago

  • Keywords has-patch added

Small variation on the patch.

@nacin
16 years ago

#4 @nacin
16 years ago

  • Keywords 3.2-early added
  • Milestone Awaiting ReviewFuture Release

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

@sivel
16 years ago

#5 @sivel
16 years ago

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

@georgestephanis
14 years ago

Updated to current trunk to accomodate for line numbers and such

#6 @nacin
14 years ago

  • Keywords commit added
  • Milestone Future Release3.5

#7 @markjaquith
14 years ago

  • Owner set to markjaquith
  • Resolutionfixed
  • Status newclosed

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.