WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#5449 closed defect (bug) (fixed)

Uploading video/3gpp content-type via wp-app.php fails

Reported by: meledin Owned by:
Milestone: 2.5 Priority: normal
Severity: normal Version:
Component: XML-RPC Keywords: has-patch
Focuses: Cc:

Description

I'm trying to upload 3gp files through wp-app.php, using rome-propono. This fails in a quite awkward manner. Namely, to store the file, wp-app does the following (cf http://trac.wordpress.org/browser/trunk/wp-app.php#L406 ):

$ext = preg_replace( '|.*/([a-z]+)|', '$1', $_SERVER['CONTENT_TYPE'] );
$slug = "$slug.$ext";

$file = wp_upload_bits( $slug, NULL, $bits);

In other words, it takes the second part of content type (e.g. image/jpeg -> jpeg), but only does so for content types with the letters a-z. On the 3gp content type video/3gpp, it manages to create a file with a slash in its name, and thus fails to save it. I have not investigated the ramifications for doing nasty stuff this way; I'd imagine they shouldn't do anything serious. Regardless...

If nothing else, this regexp should include content-types with numbers (and capitals?) to conform with the different content types available. Preferably, it should make note of the whitelist of mime types, instead of trusting the server. That seems consistent with the actions taken elsewhere, since not doing so would make later code fail for file formats with different extensions than content types.

Attachments (1)

5449.wp-app.content-type.diff (565 bytes) - added by DD32 6 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 lloydbudd6 years ago

  • Milestone set to 2.5

comment:2 DD326 years ago

  • Keywords has-patch added

While i cant test this patch(Dont have a Atom client handy), I tested the line with test inputs.

comment:3 matt6 years ago

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

(In [6393]) Allow numbers in content type to allow for types like 3gp. Fixes #5449. Hat tip: meledin, DD32.

comment:4 darkdragon6 years ago

  • Milestone changed from 2.5 to 2.4

Assumed fixed on trunk.

Note: See TracTickets for help on using tickets.