[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/libs/ -> IEContentAnalyzer.php (summary)

Simulation of Microsoft Internet Explorer's MIME type detection algorithm.

File Size: 851 lines (26 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

IEContentAnalyzer:: (9 methods):
  __construct()
  getRealMimesFromData()
  translateMimeType()
  getMimesFromData()
  getMimeTypeForVersion()
  checkTextHeaders()
  checkBinaryHeaders()
  sampleData()
  getDataFormat()


Class: IEContentAnalyzer  - X-Ref

This class simulates Microsoft Internet Explorer's terribly broken and
insecure MIME type detection algorithm. 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.
__construct()   X-Ref
No description

getRealMimesFromData( $fileName, $chunk, $proposed )   X-Ref
Get the MIME types from getMimesFromData(), but convert the result from IE's
idiosyncratic private types into something other apps will understand.

param: string $fileName the file name (unused at present)
param: string $chunk the first 256 bytes of the file
param: string $proposed the MIME type proposed by the server
return: Array: map of IE version to detected MIME type

translateMimeType( $type )   X-Ref
Translate a MIME type from IE's idiosyncratic private types into
more commonly understood type strings

param: $type
return: string

getMimesFromData( $fileName, $chunk, $proposed )   X-Ref
Get the untranslated MIME types for all known versions

param: string $fileName the file name (unused at present)
param: string $chunk the first 256 bytes of the file
param: string $proposed the MIME type proposed by the server
return: Array: map of IE version to detected MIME type

getMimeTypeForVersion( $version, $fileName, $chunk, $proposed )   X-Ref
Get the MIME type for a given named version

param: $version
param: $fileName
param: $chunk
param: $proposed
return: bool|string

checkTextHeaders( $version, $chunk )   X-Ref
Check for text headers at the start of the chunk
Confirmed same in 5 and 7.

param: $version
param: $chunk
return: bool|string

checkBinaryHeaders( $version, $chunk )   X-Ref
Check for binary headers at the start of the chunk
Confirmed same in 5 and 7.

param: $version
param: $chunk
return: bool|string

sampleData( $version, $chunk )   X-Ref
Do heuristic checks on the bulk of the data sample.
Search for HTML tags.

param: $version
param: $chunk
return: array

getDataFormat( $version, $type )   X-Ref

param: $version
param: $type
return: int|string



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1