Bug #74573 [Com]: finfo_file apk

From: Date: Thu, 11 May 2017 16:24:29 +0000
Subject: Bug #74573 [Com]: finfo_file apk
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209075@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74573&edit=1

 ID:                 74573
 Comment by:         spam2 at rhsoft dot net
 Reported by:        209721949 at qq dot com
 Summary:            finfo_file apk
 Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 Operating System:   mac
 PHP Version:        7.1.4
 Block user comment: N
 Private report:     N

 New Comment:

requinix@php.net: do you really think it's a soapbox when i had to implement
passthru("/usr/bin/file -b --mime-type $file") wrapped in output-buffers on several places
years ago beause the php implementation is unrelieable, outdated und can't distinct in known
cases between a executeable and a image while the file command can?


Previous Comments:
------------------------------------------------------------------------
[2017-05-11 16:23:51] 209721949 at qq dot com

to spam2.
thank you ! i'm not good at english ,and i don't look at your comment carefully, but now i
know it.thank you!

------------------------------------------------------------------------
[2017-05-11 16:20:24] requinix@php.net

.docx is only recognized (with what I've tested with) if the ZIP is packaged with the
[Content_Types].xml as the first entry. Reorganizing the archive turns it into a regular "Zip
archive", even though it's still a valid .docx file.

.apk can apparently be recognized as a Jar file but that's as far as it goes.

> can it be implemented in the future?
Only if standard magic databases are able to identify it, and currently it does not appear that they
can.
Just because there is a MIME identifier for a file does not mean it can be reliably identified from
the file's data. Which is what this all does, if you weren't aware.

And @spam2: stop using this bug report as your soapbox.

------------------------------------------------------------------------
[2017-05-11 16:14:35] spam2 at rhsoft dot net

> can it be implemented in the future

as you can see in my tests the reason is PHP before 7.2 is using a libmagic from the last decade and
so test it with a recent operating system and "/usr/bin/file -b --mime-type <file>"
- if it's correct chances are good that with 7.2 it will be fine or ask enough people to make
pressure backporting the stuff below so people using a distribution package have the slightest
chance to see that improved before 2020

 [2016-11-25 00:01 UTC] ab@php.net

This is fixed in 7.2 with the libmagic upgrade https://github.com/php/php-src/commit/52f5b9659fa27936d8271c4d7a6874269fbf9534
. A packport into lower branches might be tricky, as libmagic 5.29 has quite some incompatibilities
to the current version - in the data format as well as in the actual code. It could be possible as a
complete upgrade in lower branches, but would mean yet more patching, however the new libmagic needs
to be ensured stable in 7.2 first.

------------------------------------------------------------------------
[2017-05-11 16:07:41] 209721949 at qq dot com

since .apk file has it's own mime type, i think it's better to get the right mime type
directly and correct, just like other types of file, can it be implemented in the future ?

------------------------------------------------------------------------
[2017-05-11 15:48:52] spam2 at rhsoft dot net

> requinix@php.net: .apk files are ZIP archives

yeah, openoffice documents are ZIP files too *but* they are recognized because it's the
underlying libmagic - *maybe* for that case it's true and a recent libmagic would have the same
result 

but be careful to classify that as "not a bug"

with current head from https://github.com/zendtech/php-src /just beause also
test the experimental JIT at the same time

a) "php ext/fileinfo/create_data_file.php" against a Fedora 25 libmagic works
b) the sample from https://bugs.php.net/bug.php?id=67516 is correctly
   detected as image/gif and no longer application/octet-stream
c) it is proven that fileinfo in PHP is broken by deign for years

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=74573


--
Edit this bug report at https://bugs.php.net/bug.php?id=74573&edit=1


Thread (10 messages)

« previous php.bugs (#209075) next »