MediaWiki REL1_41
|
A class for reading ZIP file directories, for the purposes of upload verification. More...
Static Public Member Functions | |
static | read ( $fileName, $callback, $options=[]) |
Read a ZIP file and call a function for each file discovered in it. | |
static | readHandle ( $file, $callback, $options=[]) |
Read an opened file handle presumed to be a ZIP and call a function for each file discovered in it. | |
Protected Member Functions | |
__construct ( $file, $callback, $options) | |
Protected Attributes | |
$buffer | |
A segmented cache of the file contents. | |
$callback | |
The file data callback. | |
$data | |
$eocdr | |
Stored headers. | |
$eocdr64 | |
$eocdr64Locator | |
$file | |
The opened file resource. | |
$fileLength | |
The cached length of the file, or null if it has not been loaded yet. | |
$zip64 = false | |
The ZIP64 mode. | |
A class for reading ZIP file directories, for the purposes of upload verification.
Only a functional interface is provided: ZipFileReader::read(). No access is given to object instances.
Definition at line 32 of file ZipDirectoryReader.php.
|
protected |
resource | $file | |
callable | $callback | |
array | $options |
Definition at line 149 of file ZipDirectoryReader.php.
|
static |
Read a ZIP file and call a function for each file discovered in it.
Because this class is aimed at verification, an error is raised on suspicious or ambiguous input, instead of emulating some standard behavior.
string | $fileName | The archive file name |
callable | $callback | The callback function. It will be called for each file with a single associative array each time, with members: |
array | $options | An associative array of read options, with the option name in the key. This may currently contain: |
zip64: If this is set to true, then we will emulate a library with ZIP64 support, like OpenJDK 7. If it is set to false, then we will emulate a library with no knowledge of ZIP64.
NOTE: The ZIP64 code is untested and probably doesn't work. It turned out to be easier to just reject ZIP64 archive uploads, since they are likely to be very rare. Confirming safety of a ZIP64 file is fairly complex. What do you do with a file that is ambiguous and broken when read with a non-ZIP64 reader, but valid when read with a ZIP64 reader? This situation is normal for a valid ZIP64 file, and working out what non-ZIP64 readers will make of such a file is not trivial.
- zip-file-open-error: The file could not be opened. - zip-wrong-format: The file does not appear to be a ZIP file. - zip-bad: There was something wrong or ambiguous about the file data. - zip-unsupported: The ZIP file uses features which ZipDirectoryReader does not support.The default messages for those fatal errors are written in a way that makes sense for upload verification.
If a fatal error is returned, more information about the error will be available in the debug log.
Note that the callback function may be called any number of times before a fatal error is returned. If this occurs, the data sent to the callback function should be discarded.
Definition at line 90 of file ZipDirectoryReader.php.
|
static |
Read an opened file handle presumed to be a ZIP and call a function for each file discovered in it.
resource | $file | A seekable stream containing the archive |
callable | $callback | |
array | $options |
Definition at line 107 of file ZipDirectoryReader.php.
|
protected |
A segmented cache of the file contents.
Definition at line 119 of file ZipDirectoryReader.php.
|
protected |
The file data callback.
Definition at line 122 of file ZipDirectoryReader.php.
Referenced by __construct(), read(), and readHandle().
|
protected |
Definition at line 130 of file ZipDirectoryReader.php.
|
protected |
Stored headers.
Definition at line 128 of file ZipDirectoryReader.php.
|
protected |
Definition at line 128 of file ZipDirectoryReader.php.
|
protected |
Definition at line 128 of file ZipDirectoryReader.php.
|
protected |
The opened file resource.
Definition at line 113 of file ZipDirectoryReader.php.
Referenced by __construct(), read(), and readHandle().
|
protected |
The cached length of the file, or null if it has not been loaded yet.
Definition at line 116 of file ZipDirectoryReader.php.
|
protected |
The ZIP64 mode.
Definition at line 125 of file ZipDirectoryReader.php.