wrong mimetype when handle uploaded pdf file

RESOLVED DUPLICATE of bug 373621

Status

()

Core
General
RESOLVED DUPLICATE of bug 373621
a year ago
6 days ago

People

(Reporter: sevillacode, Unassigned)

Tracking

48 Branch
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

a year ago
Created attachment 8784732 [details]
prueba123.pdf

User Agent: Mozilla/5.0 (Windows NT 5.1; rv:48.0) Gecko/20100101 Firefox/48.0
Build ID: 20160823121617

Steps to reproduce:

Just attach pdf file into a form and check mime type from uploaded file, it returns text/html instead application/pdf. Tested on version 47 (yesterday) and 48.0.3 (update today) still same problem. 
Im using Windows XP sp3
But in another computer with Windows 10 and Firefox v.43 (up-to-date checked) it is working fine, so may be an XP's focused issue... (in XP my firefox up-to-date version is 48, and on Win 10 is 43)
 
Here is a little snippet that can be runned and checked, i'm attaching the test pdf that I used but I tested a few differents with same result

<?
if(!empty($_FILES))
    print_r($_FILES);
?>
<!DOCTYPE html>
<head></head>
<body>
<form action="" enctype="multipart/form-data" method="post">
<input type="file" name="archivo"><button type="submit">Enviar</button>
</form>
</body>


Actual results:

Here is the result with bad type, only have this issue with firefox 

Array ( [archivo] => Array ( [name] => prueba123.pdf [type] => text/html [tmp_name] => /tmp/phpTi8eJL [error] => 0 [size] => 14288 ) ) 


Expected results:

The result must be thus, as the rest of browsers do

Array ( [archivo] => Array ( [name] => prueba123.pdf [type] => application/pdf [tmp_name] => /tmp/phpqyvO70 [error] => 0 [size] => 14288 ) )
(Reporter)

Updated

a year ago
OS: Unspecified → Windows XP
Hardware: Unspecified → x86
(Reporter)

Updated

a year ago
Summary: wrong mimetype when handle upload pdf file → wrong mimetype when handle uploaded pdf file
Can you check the Content-Type field of the actual POST request?
Also, can you check the associated MIME-Type for .pdf extension in the OS level?  (in registry)
Flags: needinfo?(sevillacode)
(Reporter)

Comment 2

a year ago
(In reply to Tooru Fujisawa [:arai] from comment #1)
> Can you check the Content-Type field of the actual POST request?
> Also, can you check the associated MIME-Type for .pdf extension in the OS
> level?  (in registry)


Here is the Content-Type of post request, from sent headers
Content-Length	
14481
Content-Type	
multipart/form-data; boundary=---------------------------4534404029293


And in my system in SO level in registry:

Content Type -> REG_SZ -> application/pdf

checked on
HKEY_LOCAL_MACHINE > SOFTWARE > Adobe > PDF Owner > .pdf
(In reply to sevillacode from comment #2)
> Here is the Content-Type of post request, from sent headers
> Content-Length	
> 14481
> Content-Type	
> multipart/form-data; boundary=---------------------------4534404029293

It's Content-Type of entire form data.
Can you check the Content-Type of the pdf file's part?


> And in my system in SO level in registry:
> 
> Content Type -> REG_SZ -> application/pdf
> 
> checked on
> HKEY_LOCAL_MACHINE > SOFTWARE > Adobe > PDF Owner > .pdf

What's the default value of HKEY_CLASSES_ROOT > .pdf ?
(Reporter)

Comment 4

a year ago
(In reply to Tooru Fujisawa [:arai] from comment #3)
> (In reply to sevillacode from comment #2)
> 
> It's Content-Type of entire form data.
> Can you check the Content-Type of the pdf file's part?


I modified my control snippet to this, I think that thus I retrieve that you are asking for

<?
if(!empty($_FILES)){
    print_r($_FILES);
    echo '<br>';
    $finfo = new finfo(FILEINFO_MIME);
    $type = $finfo->file($_FILES['archivo']['tmp_name']);
    var_dump($type);
}
?>

And it return

Array ( [archivo] => Array ( [name] => prueba123.pdf [type] => text/html [tmp_name] => /tmp/phpeF1Ypn [error] => 0 [size] => 14288 ) )
string(31) "application/pdf; charset=binary"

So i think that the answer is: application/pdf; charset=binary

If I'm doing wrong please let me know how do it



> What's the default value of HKEY_CLASSES_ROOT > .pdf ?

In default entry the value is: AcroExch.Document.11
And are too another entry called Content Type with value: application/pdf
I'm not sure if the script shows the actual request body.


You can check the raw request body by the following steps:
  1. open the form with Firefox
  2. open Developer Tools "Network" tab
  3. choose the pdf file in the form
  4. send the form
  5. click the POST request in the "Network" tab
  6. click "Edit and Resend" button
  7. there is "Request Body" textbox

in the textbox, the body is shown.
You'll see something like the following

> ...
> -----------------------------14764951501280444965504900168
> Content-Disposition: form-data; name="NAME_OF_THE_FILE_FIELD"; filename="FILENAME_OF_THE_PDF_FILE"
> Content-Type: CONTENT_TYPE_OF_THE_PDF_FILE
> 
> CONTENT_OF_THE_PDF_FILE
> ...


(In reply to sevillacode from comment #4)
> > What's the default value of HKEY_CLASSES_ROOT > .pdf ?
> 
> In default entry the value is: AcroExch.Document.11
> And are too another entry called Content Type with value: application/pdf

in that case it should use "application/pdf"
This might be related to bug 373621.
(Reporter)

Comment 7

a year ago
(In reply to Tooru Fujisawa [:arai] from comment #6)

> 
> You can check the raw request body by the following steps:
> 1. ...
>

Here you have:

-----------------------------6531616226228
Content-Disposition: form-data; name="archivo"; filename="prueba123.pdf"
Content-Type: text/html

(here continues the pdf file itself)

> 
> in that case it should use "application/pdf"
> 

I have it wrong in registry? I never didn't change it. I don't understand at all...
can you check mimeTypes.rdf in your profile?
bug 373621 says it can override the MIME-Type for upload (and it's fixed on Firefox 50)
(Reporter)

Comment 9

a year ago
I checked the file and I think that I found that you need, but i'm not familiar with these files and i don't know what are looking for exactly

<RDF:Description RDF:about="urn:mimetype:text/html"
                   NC:description="Adobe Acrobat Document"
                   NC:value="text/html"
                   NC:editable="true">
    <NC:fileExtensions>pdf</NC:fileExtensions>
    <NC:fileExtensions>htm</NC:fileExtensions>
    <NC:handlerProp RDF:resource="urn:mimetype:handler:text/html"/>
  </RDF:Description>

As you says, if this is the correct snippet that you ask and if this override the whole post upload mime type, there says NC:value="text/html" instead "application/pdf"

Here you have the complete file if you want to look it
http://pastebin.com/qQGVexES
thanks, it looks like this is a dupe of bug 373621.
Status: UNCONFIRMED → RESOLVED
Last Resolved: a year ago
Flags: needinfo?(sevillacode)
Resolution: --- → DUPLICATE
Duplicate of bug: 373621
Moving from Core::Untriaged to Core::General https://bugzilla.mozilla.org/show_bug.cgi?id=1407598
Component: Untriaged → General
You need to log in before you can comment on or make changes to this bug.