Merge branch 'MDL-75488-master' of https://github.com/stevandoMoodle/moodle
This commit is contained in:
@@ -585,7 +585,7 @@ All rights reserved.</copyright>
|
||||
<location>zipstream</location>
|
||||
<name>ZipStream-PHP</name>
|
||||
<description>PHP ZIP Streaming Library</description>
|
||||
<version>2.1.0</version>
|
||||
<version>2.2.0</version>
|
||||
<license>MIT</license>
|
||||
<repository>https://github.com/maennchen/ZipStream-PHP</repository>
|
||||
<copyrights>
|
||||
|
||||
@@ -108,6 +108,7 @@ class Bigint
|
||||
/**
|
||||
* Check if is over 32
|
||||
*
|
||||
* @psalm-suppress ArgumentTypeCoercion
|
||||
* @param bool $force
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
namespace ZipStream;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use RuntimeException;
|
||||
use ZipStream\Exception\EncodingException;
|
||||
use ZipStream\Exception\FileNotFoundException;
|
||||
use ZipStream\Exception\FileNotReadableException;
|
||||
@@ -75,8 +76,9 @@ class File
|
||||
* @var resource
|
||||
*/
|
||||
private $deflate;
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
* @var \HashContext
|
||||
*/
|
||||
private $hash;
|
||||
|
||||
@@ -291,6 +293,13 @@ class File
|
||||
$this->version = Version::ZIP64();
|
||||
}
|
||||
|
||||
if ($this->bits & self::BIT_EFS_UTF8) {
|
||||
// Put the tricky entry to
|
||||
// force Linux unzip to lookup EFS flag.
|
||||
$fields[] = ['v', 0x5653]; // Choose 'ZS' for proprietary usage
|
||||
$fields[] = ['v', 0x0000]; // zero length
|
||||
}
|
||||
|
||||
return ZipStream::packFields($fields);
|
||||
}
|
||||
|
||||
@@ -366,7 +375,8 @@ class File
|
||||
|
||||
protected function deflateInit(): void
|
||||
{
|
||||
$this->hash = hash_init(self::HASH_ALGORITHM);
|
||||
$hash = hash_init(self::HASH_ALGORITHM);
|
||||
$this->hash = $hash;
|
||||
if ($this->method->equals(Method::DEFLATE())) {
|
||||
$this->deflate = deflate_init(
|
||||
ZLIB_ENCODING_RAW,
|
||||
|
||||
@@ -3,6 +3,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZipStream\Option;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
final class Archive
|
||||
{
|
||||
const DEFAULT_DEFLATE_LEVEL = 6;
|
||||
@@ -104,7 +106,7 @@ final class Archive
|
||||
private $deflateLevel = 6;
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
* @var StreamInterface|resource
|
||||
*/
|
||||
private $outputStream;
|
||||
|
||||
@@ -228,7 +230,7 @@ final class Archive
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
* @return StreamInterface|resource
|
||||
*/
|
||||
public function getOutputStream()
|
||||
{
|
||||
@@ -236,7 +238,7 @@ final class Archive
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $outputStream
|
||||
* @param StreamInterface|resource $outputStream
|
||||
*/
|
||||
public function setOutputStream($outputStream): void
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
namespace ZipStream\Option;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
|
||||
final class File
|
||||
{
|
||||
@@ -20,7 +21,7 @@ final class File
|
||||
*/
|
||||
private $deflateLevel;
|
||||
/**
|
||||
* @var DateTime
|
||||
* @var DateTimeInterface
|
||||
*/
|
||||
private $time;
|
||||
/**
|
||||
@@ -83,17 +84,17 @@ final class File
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
* @return DateTimeInterface
|
||||
*/
|
||||
public function getTime(): DateTime
|
||||
public function getTime(): DateTimeInterface
|
||||
{
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $time
|
||||
* @param DateTimeInterface $time
|
||||
*/
|
||||
public function setTime(DateTime $time): void
|
||||
public function setTime(DateTimeInterface $time): void
|
||||
{
|
||||
$this->time = $time;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class Stream implements StreamInterface
|
||||
{
|
||||
try {
|
||||
$this->seek(0);
|
||||
} catch (\RuntimeException $e) {}
|
||||
} catch (RuntimeException $e) {}
|
||||
return (string) stream_get_contents($this->stream);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class Stream implements StreamInterface
|
||||
* PHP $whence values for `fseek()`. SEEK_SET: Set position equal to
|
||||
* offset bytes SEEK_CUR: Set position to current location plus offset
|
||||
* SEEK_END: Set position to end-of-stream plus offset.
|
||||
* @throws \RuntimeException on failure.
|
||||
* @throws RuntimeException on failure.
|
||||
*/
|
||||
public function seek($offset, $whence = SEEK_SET): void
|
||||
{
|
||||
@@ -136,7 +136,7 @@ class Stream implements StreamInterface
|
||||
* Returns the current position of the file read/write pointer
|
||||
*
|
||||
* @return int Position of the file pointer
|
||||
* @throws \RuntimeException on error.
|
||||
* @throws RuntimeException on error.
|
||||
*/
|
||||
public function tell(): int
|
||||
{
|
||||
@@ -165,7 +165,7 @@ class Stream implements StreamInterface
|
||||
*
|
||||
* @see seek()
|
||||
* @link http://www.php.net/manual/en/function.fseek.php
|
||||
* @throws \RuntimeException on failure.
|
||||
* @throws RuntimeException on failure.
|
||||
*/
|
||||
public function rewind(): void
|
||||
{
|
||||
@@ -177,7 +177,7 @@ class Stream implements StreamInterface
|
||||
*
|
||||
* @param string $string The string that is to be written.
|
||||
* @return int Returns the number of bytes written to the stream.
|
||||
* @throws \RuntimeException on failure.
|
||||
* @throws RuntimeException on failure.
|
||||
*/
|
||||
public function write($string): int
|
||||
{
|
||||
@@ -197,7 +197,11 @@ class Stream implements StreamInterface
|
||||
*/
|
||||
public function isWritable(): bool
|
||||
{
|
||||
return preg_match('/[waxc+]/', $this->getMetadata('mode')) === 1;
|
||||
$mode = $this->getMetadata('mode');
|
||||
if (!is_string($mode)) {
|
||||
throw new RuntimeException('Could not get stream mode from metadata!');
|
||||
}
|
||||
return preg_match('/[waxc+]/', $mode) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +233,11 @@ class Stream implements StreamInterface
|
||||
*/
|
||||
public function isReadable(): bool
|
||||
{
|
||||
return preg_match('/[r+]/', $this->getMetadata('mode')) === 1;
|
||||
$mode = $this->getMetadata('mode');
|
||||
if (!is_string($mode)) {
|
||||
throw new RuntimeException('Could not get stream mode from metadata!');
|
||||
}
|
||||
return preg_match('/[r+]/', $mode) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -312,12 +312,9 @@ class ZipStream
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // create a temporary file stream and write text to it
|
||||
* $fp = tmpfile();
|
||||
* fwrite($fp, 'The quick brown fox jumped over the lazy dog.');
|
||||
*
|
||||
* $stream = $response->getBody();
|
||||
* // add a file named 'streamfile.txt' from the content of the stream
|
||||
* $x->addFileFromPsr7Stream('streamfile.txt', $fp);
|
||||
* $x->addFileFromPsr7Stream('streamfile.txt', $stream);
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -459,7 +456,13 @@ class ZipStream
|
||||
}
|
||||
$this->need_headers = false;
|
||||
|
||||
fwrite($this->opt->getOutputStream(), $str);
|
||||
$outputStream = $this->opt->getOutputStream();
|
||||
|
||||
if ($outputStream instanceof StreamInterface) {
|
||||
$outputStream->write($str);
|
||||
} else {
|
||||
fwrite($outputStream, $str);
|
||||
}
|
||||
|
||||
if ($this->opt->isFlushOutput()) {
|
||||
// flush output buffer if it is on and flushable
|
||||
|
||||
Reference in New Issue
Block a user