Edit report at http://pear.php.net/bugs/bug.php?id=17703&edit=1
ID: 17703
Updated by: jens@bierkandt.org
Reported By: jens at bierkandt dot org
Summary: MimeType validated incorrectly
Status: Open
Type: Bug
Package: HTTP_Download
Operating System: OpenSuSE 11.0
Package Version: 1.1.3
PHP Version: Irrelevant
Roadmap Versions:
New Comment:
Update: video/3gpp does not work, video/mp4,audio/mp3 works without
patch.
Previous Comments:
------------------------------------------------------------------------
[2010-08-14 19:49:11] schtorch
Description:
------------
When defining a mime type in setContentType(), it is verified by
HTTP_Download, but incorrectly. If the mime type contains a number (e.g.
video/mp4,video/mp3), the script throws a Pear error.
Patch:
--- Download_old.php 2010-08-14 21:37:07.000000000 +0200
+++ Download.php 2010-08-14 21:37:50.000000000 +0200
@@ -554,7 +554,7 @@
*/
function setContentType($content_type =
'application/x-octetstream')
{
- if (!preg_match('/^[a-z]+\w*\/[a-z]+[\w.;= -]*$/',
$content_type)) {
+ if (!preg_match('/^[a-z]+\w*\/[a-z0-9]+[\w.;= -]*$/',
$content_type)) {
return PEAR::raiseError(
"Invalid content type '$content_type' supplied.",
HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE
Test script:
---------------
$dl = new HTTP_Download();
$dl->setFile($file);
$dl->setContentDisposition(HTTP_DOWNLOAD_ATTACHMENT, basename($file));
$dl->setContentType('video/mp4');
$dl->send();
Expected result:
----------------
Correct mime type during download.
Actual result:
--------------
Mime type is not set.
------------------------------------------------------------------------