Ticket #5449 (closed defect: fixed)

Opened 9 months ago

Last modified 9 months ago

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

Reported by: meledin Assigned to: anonymous
Priority: normal Milestone: 2.5
Component: XML-RPC Version:
Severity: normal Keywords: has-patch
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

5449.wp-app.content-type.diff (0.6 kB) - added by DD32 on 12/11/07 12:19:30.

Change History

12/10/07 16:05:26 changed by lloydbudd

  • milestone set to 2.5.

12/11/07 12:19:19 changed by DD32

  • keywords set to has-patch.

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

12/11/07 12:19:30 changed by DD32

  • attachment 5449.wp-app.content-type.diff added.

12/16/07 21:44:49 changed by matt

  • status changed from new to closed.
  • resolution set to fixed.

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

12/16/07 22:10:18 changed by darkdragon

  • milestone changed from 2.5 to 2.4.

Assumed fixed on trunk.