Reduce false positives for PHP in MimeMagic
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 6 Nov 2009 21:03:19 +0000 (21:03 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 6 Nov 2009 21:03:19 +0000 (21:03 +0000)
commit777386da76e621e680942bc90d5c00900afafd58
tree9ffc2fa01d9747eabc71a87b17539c84f29ab781
parent06714f6cde16502ed41a1d48f72002fbf9395762
Reduce false positives for PHP in MimeMagic

(bug 16583) This was detecting PHP if any of a few three-byte strings
occurred anywhere in the first 1024 bytes of the file.  This is too
paranoid -- it creates a significant number of false positives for
binary files, reportedly on the order of about one every 4096 uploads.

It's hard to see what security advantage this check every conveyed,
because it only looks in the first 1024 bytes anyway.  For the purposes
of upload it could surely be removed entirely, but I didn't check all
callers, so maybe some caller wants to guess whether the file is PHP for
some purpose other than banning it.  So for now I only removed the
checks for the shortest strings, which were most likely to get hit.
RELEASE-NOTES
includes/MimeMagic.php