Public Member Functions | |
__construct () | |
constructor | |
getRealMimesFromData ($fileName, $chunk, $proposed) | |
Get the MIME types from getMimesFromData(), but convert the result from IE's idiosyncratic private types into something other apps will understand. | |
translateMimeType ($type) | |
Translate a MIME type from IE's idiosyncratic private types into more commonly understood type strings. | |
getMimesFromData ($fileName, $chunk, $proposed) | |
Get the untranslated MIME types for all known versions. | |
Protected Member Functions | |
getMimeTypeForVersion ($version, $fileName, $chunk, $proposed) | |
Get the MIME type for a given named version. | |
sampleData ($version, $chunk) | |
Do heuristic checks on the bulk of the data sample. | |
getDataFormat ($version, $type) | |
Protected Attributes | |
$baseTypeTable | |
Relevant data taken from the type table in IE 5. | |
$addedTypes | |
Changes to the type table in later versions of IE. | |
$registry | |
An approximation of the "Content Type" values in HKEY_CLASSES_ROOT in a typical Windows installation. | |
$versions = array( 'ie05', 'ie06', 'ie07', 'ie07.strict', 'ie07.nohtml' ) | |
IE versions which have been analysed to bring you this class, and for which some substantive difference exists. | |
$typeTable = array() | |
Type table with versions expanded. | |
Private Member Functions | |
checkTextHeaders ($version, $chunk) | |
Check for text headers at the start of the chunk Confirmed same in 5 and 7. | |
checkBinaryHeaders ($version, $chunk) | |
Check for binary headers at the start of the chunk Confirmed same in 5 and 7. |
It can be used to check web uploads with an apparently safe type, to see if IE will reinterpret them to produce something dangerous.
It is full of bugs and strange design choices should not under any circumstances be used to determine a MIME type to present to a user or client. (Apple Safari developers, this means you too.)
This class is based on a disassembly of IE 5.0, 6.0 and 7.0. Although I have attempted to ensure that this code works in exactly the same way as Internet Explorer, it does not share any source code, or creative choices such as variable names, thus I (Tim Starling) claim copyright on it.
It may be redistributed without restriction. To aid reuse, this class does not depend on any MediaWiki module.
Definition at line 21 of file IEContentAnalyzer.php.
IEContentAnalyzer::__construct | ( | ) |
constructor
Definition at line 309 of file IEContentAnalyzer.php.
References $addedTypes, and $version.
IEContentAnalyzer::checkBinaryHeaders | ( | $ | version, | |
$ | chunk | |||
) | [private] |
Check for binary headers at the start of the chunk Confirmed same in 5 and 7.
Definition at line 567 of file IEContentAnalyzer.php.
Referenced by getMimeTypeForVersion().
IEContentAnalyzer::checkTextHeaders | ( | $ | version, | |
$ | chunk | |||
) | [private] |
Check for text headers at the start of the chunk Confirmed same in 5 and 7.
Definition at line 544 of file IEContentAnalyzer.php.
Referenced by getMimeTypeForVersion().
IEContentAnalyzer::getDataFormat | ( | $ | version, | |
$ | type | |||
) | [protected] |
Definition at line 811 of file IEContentAnalyzer.php.
References $type, and $version.
Referenced by getMimeTypeForVersion().
IEContentAnalyzer::getMimesFromData | ( | $ | fileName, | |
$ | chunk, | |||
$ | proposed | |||
) |
Get the untranslated MIME types for all known versions.
string | $fileName The file name (unused at present) | |
string | $chunk The first 256 bytes of the file | |
string | $proposed The MIME type proposed by the server |
Definition at line 368 of file IEContentAnalyzer.php.
References $version, and getMimeTypeForVersion().
Referenced by getRealMimesFromData().
IEContentAnalyzer::getMimeTypeForVersion | ( | $ | version, | |
$ | fileName, | |||
$ | chunk, | |||
$ | proposed | |||
) | [protected] |
Get the MIME type for a given named version.
Definition at line 379 of file IEContentAnalyzer.php.
References $ext, $result, $type, $version, checkBinaryHeaders(), checkTextHeaders(), getDataFormat(), and sampleData().
Referenced by getMimesFromData().
IEContentAnalyzer::getRealMimesFromData | ( | $ | fileName, | |
$ | chunk, | |||
$ | proposed | |||
) |
Get the MIME types from getMimesFromData(), but convert the result from IE's idiosyncratic private types into something other apps will understand.
string | $fileName The file name (unused at present) | |
string | $chunk The first 256 bytes of the file | |
string | $proposed The MIME type proposed by the server |
Definition at line 332 of file IEContentAnalyzer.php.
References getMimesFromData().
IEContentAnalyzer::sampleData | ( | $ | version, | |
$ | chunk | |||
) | [protected] |
Do heuristic checks on the bulk of the data sample.
Search for HTML tags.
Definition at line 665 of file IEContentAnalyzer.php.
References $offset, and $version.
Referenced by getMimeTypeForVersion().
IEContentAnalyzer::translateMimeType | ( | $ | type | ) |
Translate a MIME type from IE's idiosyncratic private types into more commonly understood type strings.
Definition at line 342 of file IEContentAnalyzer.php.
References $type.
IEContentAnalyzer::$addedTypes [protected] |
Initial value:
array( 'ie07' => array( 'text' => array( 'text/xml', 'application/xml' ) ), )
Definition at line 49 of file IEContentAnalyzer.php.
Referenced by __construct().
IEContentAnalyzer::$baseTypeTable [protected] |
Initial value:
array( 'ambiguous' => array( 'text/plain', 'application/octet-stream', 'application/x-netcdf', ), 'text' => array( 'text/richtext', 'image/x-bitmap', 'application/postscript', 'application/base64', 'application/macbinhex40', 'application/x-cdf', 'text/scriptlet' ), 'binary' => array( 'application/pdf', 'audio/x-aiff', 'audio/basic', 'audio/wav', 'image/gif', 'image/pjpeg', 'image/jpeg', 'image/tiff', 'image/x-png', 'image/png', 'image/bmp', 'image/x-jg', 'image/x-art', 'image/x-emf', 'image/x-wmf', 'video/avi', 'video/x-msvideo', 'video/mpeg', 'application/x-compressed', 'application/x-zip-compressed', 'application/x-gzip-compressed', 'application/java', 'application/x-msdownload' ), 'html' => array( 'text/html' ), )
Definition at line 25 of file IEContentAnalyzer.php.
IEContentAnalyzer::$registry [protected] |
An approximation of the "Content Type" values in HKEY_CLASSES_ROOT in a typical Windows installation.
Used for extension to MIME type mapping if detection fails.
Definition at line 61 of file IEContentAnalyzer.php.
IEContentAnalyzer::$typeTable = array() [protected] |
IEContentAnalyzer::$versions = array( 'ie05', 'ie06', 'ie07', 'ie07.strict', 'ie07.nohtml' ) [protected] |
IE versions which have been analysed to bring you this class, and for which some substantive difference exists.
These will appear as keys in the return value of getRealMimesFromData(). The names are chosen to sort correctly.
Definition at line 301 of file IEContentAnalyzer.php.