FAQ
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.

------------------------------------------------------------------------

Search Discussions

  • Daniel Oconnor at Aug 15, 2010 at 4:34 am
    Edit report at http://pear.php.net/bugs/bug.php?id=17703&edit=1

    ID: 17703
    Updated by: daniel.oconnor@gmail.com
    Reported By: jens at bierkandt dot org
    Summary: MimeType validated incorrectly
    -Status: Open
    +Status: Analyzed
    Type: Bug
    Package: HTTP_Download
    Operating System: OpenSuSE 11.0
    Package Version: 1.1.3
    PHP Version: Irrelevant
    Roadmap Versions:
    New Comment:

    -Status: Open
    +Status: Analyzed
    Thanks for the patch Jens


    Previous Comments:
    ------------------------------------------------------------------------

    [2010-08-14 20:00:10] schtorch

    Update: video/3gpp does not work, video/mp4,audio/mp3 works without
    patch.

    ------------------------------------------------------------------------

    [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.

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedAug 14, '10 at 8:00p
activeAug 15, '10 at 4:34a
posts2
users2
websitepear.php.net

2 users in discussion

Daniel Oconnor: 1 post Jens: 1 post

People

Translate

site design / logo © 2022 Grokbase