X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FZipDirectoryReader.php;h=307efcea8de51dd5269e5bfef331ba4127e0a5ab;hb=9c2e3197b9f84ff6ede0d763c1816782923e363d;hp=ccdf2bb110114798bd7defdd9d9e8bddbfa07c97;hpb=5abe15bb9daa6197544087688d73ba11eb7fa801;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ZipDirectoryReader.php b/includes/ZipDirectoryReader.php index ccdf2bb110..307efcea8d 100644 --- a/includes/ZipDirectoryReader.php +++ b/includes/ZipDirectoryReader.php @@ -34,10 +34,10 @@ class ZipDirectoryReader { * * Because this class is aimed at verification, an error is raised on * suspicious or ambiguous input, instead of emulating some standard - * behaviour. + * behavior. * - * @param $fileName string The archive file name - * @param $callback Array The callback function. It will be called for each file + * @param string $fileName The archive file name + * @param array $callback The callback function. It will be called for each file * with a single associative array each time, with members: * * - name: The file name. Directories conventionally have a trailing @@ -47,7 +47,7 @@ class ZipDirectoryReader { * * - size: The uncompressed file size * - * @param $options Array An associative array of read options, with the option + * @param 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 @@ -162,7 +162,7 @@ class ZipDirectoryReader { || $this->eocdr['CD entries total'] == 0xffff ) { $this->error( 'zip-unsupported', 'Central directory header indicates ZIP64, ' . - 'but we are in legacy mode. Rejecting this upload is necessary to avoid '. + 'but we are in legacy mode. Rejecting this upload is necessary to avoid ' . 'opening vulnerabilities on clients using OpenJDK 7 or later.' ); } @@ -181,7 +181,7 @@ class ZipDirectoryReader { * Throw an error, and log a debug message */ function error( $code, $debugMessage ) { - wfDebug( __CLASS__.": Fatal error: $debugMessage\n" ); + wfDebug( __CLASS__ . ": Fatal error: $debugMessage\n" ); throw new ZipDirectoryReaderError( $code ); } @@ -220,7 +220,7 @@ class ZipDirectoryReader { if ( $structSize + $this->eocdr['file comment length'] != strlen( $block ) - $sigPos ) { $this->error( 'zip-bad', 'trailing bytes after the end of the file comment' ); } - if ( $this->eocdr['disk'] !== 0 + if ( $this->eocdr['disk'] !== 0 || $this->eocdr['CD start disk'] !== 0 ) { $this->error( 'zip-unsupported', 'more than one disk (in EOCDR)' ); @@ -262,7 +262,7 @@ class ZipDirectoryReader { * may replace the regular "end of central directory record" in ZIP64 files. */ function readZip64EndOfCentralDirectoryRecord() { - if ( $this->eocdr64Locator['eocdr64 start disk'] != 0 + if ( $this->eocdr64Locator['eocdr64 start disk'] != 0 || $this->eocdr64Locator['number of disks'] != 0 ) { $this->error( 'zip-unsupported', 'more than one disk (in EOCDR64 locator)' ); @@ -286,7 +286,7 @@ class ZipDirectoryReader { if ( $data['signature'] !== "PK\x06\x06" ) { $this->error( 'zip-bad', 'wrong signature on Zip64 end of central directory record' ); } - if ( $data['disk'] !== 0 + if ( $data['disk'] !== 0 || $data['CD start disk'] !== 0 ) { $this->error( 'zip-unsupported', 'more than one disk (in EOCDR64)' ); @@ -327,7 +327,7 @@ class ZipDirectoryReader { $offset = $this->eocdr['CD offset']; $numEntries = $this->eocdr['CD entries total']; $endPos = $this->eocdr['position']; - if ( $size == 0xffffffff + if ( $size == 0xffffffff || $offset == 0xffffffff || $numEntries == 0xffff ) { @@ -395,7 +395,7 @@ class ZipDirectoryReader { $data += $this->unpack( $block, $variableInfo, $pos ); $pos += $this->getStructSize( $variableInfo ); - if ( $this->zip64 && ( + if ( $this->zip64 && ( $data['compressed size'] == 0xffffffff || $data['uncompressed size'] == 0xffffffff || $data['local header offset'] == 0xffffffff ) ) @@ -494,8 +494,8 @@ class ZipDirectoryReader { * Get the file contents from a given offset. If there are not enough bytes * in the file to satisfy the request, an exception will be thrown. * - * @param $start int The byte offset of the start of the block. - * @param $length int The number of bytes to return. If omitted, the remainder + * @param int $start The byte offset of the start of the block. + * @param int $length The number of bytes to return. If omitted, the remainder * of the file will be returned. * * @return string @@ -538,7 +538,7 @@ class ZipDirectoryReader { * of length self::SEGSIZE. The result is cached. This is a helper function * for getBlock(). * - * If there are not enough bytes in the file to satsify the request, the + * If there are not enough bytes in the file to satisfy the request, the * return value will be truncated. If a request is made for a segment beyond * the end of the file, an empty string will be returned. * @return string @@ -570,7 +570,7 @@ class ZipDirectoryReader { $size = 0; foreach ( $struct as $type ) { if ( is_array( $type ) ) { - list( $typeName, $fieldSize ) = $type; + list( , $fieldSize ) = $type; $size += $fieldSize; } else { $size += $type; @@ -583,9 +583,9 @@ class ZipDirectoryReader { * Unpack a binary structure. This is like the built-in unpack() function * except nicer. * - * @param $string string The binary data input + * @param string $string The binary data input * - * @param $struct array An associative array giving structure members and their + * @param array $struct An associative array giving structure members and their * types. In the key is the field name. The value may be either an * integer, in which case the field is a little-endian unsigned integer * encoded in the given number of bytes, or an array, in which case the @@ -594,7 +594,7 @@ class ZipDirectoryReader { * - "string": The second array element gives the length of string. * Not null terminated. * - * @param $offset int The offset into the string at which to start unpacking. + * @param int $offset The offset into the string at which to start unpacking. * * @throws MWException * @return array Unpacked associative array. Note that large integers in the input @@ -618,7 +618,7 @@ class ZipDirectoryReader { $pos += $fieldSize; break; default: - throw new MWException( __METHOD__.": invalid type \"$typeName\"" ); + throw new MWException( __METHOD__ . ": invalid type \"$typeName\"" ); } } else { // Unsigned little-endian integer @@ -651,7 +651,7 @@ class ZipDirectoryReader { * boolean. * * @param $value integer - * @param $bitIndex int The index of the bit, where 0 is the LSB. + * @param int $bitIndex The index of the bit, where 0 is the LSB. * @return bool */ function testBit( $value, $bitIndex ) {