Bug 127008 - pdf with invalid extension (doc.pdf.php) is resolved with invalid mine type
Summary: pdf with invalid extension (doc.pdf.php) is resolved with invalid mine type
Status: RESOLVED NOT A BUG
Alias: None
Product: kpdf
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR wishlist
Target Milestone: ---
Assignee: Albert Astals Cid
URL:
Keywords:
: 138192 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-05-09 11:53 UTC by Pinky
Modified: 2008-12-09 21:07 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pinky 2006-05-09 11:53:11 UTC
Version:           kdelibs-3.5.2 (-r4) (using KDE KDE 3.5.2)
Installed from:    Gentoo Packages
Compiler:          gcc version 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9) 
OS:                Linux

At first I try open pdf document form web, I use kdpf.
Document name is document.php, but it is pdf file
if I try open it with kpdf, but it shows:

kpdf: WARNING: Unknown mimetype 'application/x-php'.

(www server return valid [application/pdf])
If I try determine vhere problem is i got:

kfile document.php
document.php: PHP skript (application/x-php)
document.php: Cannot determine metadata

kfile document.php.pdf
document.php.pdf: PDF dokument (application/pdf)

I try file tooo:
file document.php.pdf
document.php.pdf: PDF document, version 1.4

after rename to document.pdf it work :)
Comment 1 Thiago Macieira 2006-05-16 17:16:52 UTC
We need an example to reproduce this. Are you opening a local file or something on a server? If it's a server, can you give us the URL?
Comment 2 Pinky 2006-05-16 23:16:06 UTC
It is simple, but I have the ability to make it complicated.

Rename file on disk from something.pdf to something.php a try it open with kpdf.

The same do browser(Mozilla), download file from web, store it in /tmp and call kpdf to open them. Www server return valid document type (in http head) and therefore mozilla call kpdf to open them, but kpdf does not do this.

http://www.vscht.cz/document.php?docId=1283

Comment 3 Thiago Macieira 2006-05-17 15:56:34 UTC
Ok, I see.

Albert: any ideas?
Comment 4 Albert Astals Cid 2006-05-17 19:34:36 UTC
For local files i'd say it's a kdelibs problem, we ask the mimetype of the file and if it's not pdf we do not open it, for webfiles it should work, at least it works here both doing
konqueror http://www.vscht.cz/document.php?docId=1283
that gives me kpdf embedded in konqueror, and
kpdf http://www.vscht.cz/document.php?docId=1283
that gives me kpdf standalone
Comment 5 Thiago Macieira 2006-05-17 19:39:23 UTC
That means that the MIME type detection for PHP is being done on extensions,  not on contents.

Does KPDF require kdelibs to tell it the MIME type? Can't it try to open as PDF anyways and complain if the file isn't the correct format?

I imagine that oKular would have problems down the line with this, though...
Comment 6 Albert Astals Cid 2006-05-19 20:02:35 UTC
Not possible at the moment since kpdf already internally has some structure for plugins so we need to get the correct mimetype, maybe we are not doing it the right way but...
Comment 7 Albert Astals Cid 2006-05-19 20:16:46 UTC
Closing the bug as not recognizing foo.php as a pdf file is a kdelibs "feature", open a bug against it if you want.

Also both kpdf and konqueror are working here with http://www.vscht.cz/document.php?docId=1283

Please reopen the bug if you do not agree or kpdf/konqueror are failing when going to http://www.vscht.cz/document.php?docId=1283

Thanks for reporting.
Comment 8 Albert Astals Cid 2006-12-13 20:35:41 UTC
*** Bug 138192 has been marked as a duplicate of this bug. ***
Comment 9 Ben Bucksch 2008-12-09 21:07:01 UTC
I can see that kfile is buggy/stupid:
$ kfile index.pdf
index.pdf: PDF-Dokument (application/pdf)
$ cp index.pdf index.html
$ kfile index.html
index.html: HTML-Dokument (text/html)
$ file index.html
index.html: PDF document, version 1.3

In other words, |kfile| only looks at the file extension. |file| correctly determines the file type based on the content. If anything, |kfile| should be smarter than |file|. I'll file a bug against kfile.

Independent of that, I do not agree with the resolution. If I specifically open a file with KPDF, then you should assume that it's a PDF file (kfile is irrelevant in this situation) and try to open it. Only when the PDF parser fails (based on the file content) should an error be shown.

My reproduction: Web server (Handelsblatt "News am Abend" in this case) delivers file with URL .../6754548/index.html, mimetype "application/pdf". Firefox uses the "external helper app" code path, I specify KPDF as app to open the file with, Firefox downloads it and saves it as "/tmp/index.html" (based on the URL), and launches "kpdf /tmp/index.html". KPDF fails. Sure, Firefox could change the file extensions, but that may break other things.

If I launch "kpdf foo.bar", just assume it's a PDF file. Why else would I launch KPDF with it?

Please REOPEN. I don't have the access rights to do that.