updated-packages
This commit is contained in:
76
vendor/league/flysystem/CODE_OF_CONDUCT.md
vendored
Normal file
76
vendor/league/flysystem/CODE_OF_CONDUCT.md
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at info+flysystem@frankdejonge.nl. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
2
vendor/league/flysystem/LICENSE
vendored
2
vendor/league/flysystem/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2013-2018 Frank de Jonge
|
||||
Copyright (c) 2013-2019 Frank de Jonge
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
16
vendor/league/flysystem/SECURITY.md
vendored
Normal file
16
vendor/league/flysystem/SECURITY.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 1.0.x | :white_check_mark: |
|
||||
| 2.0.x | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
When you've encountered a security vulnerability, please disclose it securely.
|
||||
|
||||
The security process is described at:
|
||||
[https://flysystem.thephpleague.com/docs/security/](https://flysystem.thephpleague.com/docs/security/)
|
||||
|
||||
28
vendor/league/flysystem/composer.json
vendored
28
vendor/league/flysystem/composer.json
vendored
@@ -1,11 +1,18 @@
|
||||
{
|
||||
"name": "league/flysystem",
|
||||
"type": "library",
|
||||
"description": "Filesystem abstraction: Many filesystems, one API.",
|
||||
"keywords": [
|
||||
"filesystem", "filesystems", "files", "storage", "dropbox", "aws",
|
||||
"abstraction", "s3", "ftp", "sftp", "remote", "webdav",
|
||||
"file systems", "cloud", "cloud files", "rackspace", "copy.com"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"type": "other",
|
||||
"url": "https://offset.earth/frankdejonge"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
@@ -14,12 +21,13 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"ext-fileinfo": "*"
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"ext-fileinfo": "*",
|
||||
"league/mime-type-detection": "^1.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "^3.4",
|
||||
"phpunit/phpunit": "^5.7.10"
|
||||
"phpspec/prophecy": "^1.11.1",
|
||||
"phpunit/phpunit": "^8.5.8"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -29,13 +37,9 @@
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"League\\Flysystem\\Stub\\": "stub/"
|
||||
},
|
||||
"files": [
|
||||
"tests/PHPUnitHacks.php"
|
||||
]
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"ext-fileinfo": "Required for MimeType",
|
||||
"league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem",
|
||||
"league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files",
|
||||
"league/flysystem-azure": "Allows you to use Windows Azure Blob storage",
|
||||
@@ -53,12 +57,12 @@
|
||||
"conflict": {
|
||||
"league/flysystem-sftp": "<1.0.6"
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"phpstan": "php phpstan.php"
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/league/flysystem/deprecations.md
vendored
2
vendor/league/flysystem/deprecations.md
vendored
@@ -16,4 +16,4 @@ your application this is Flysystem) to leak into the application. The most
|
||||
important part for Flysystem is that it improves portability and creates a
|
||||
solid boundary between your application core and the infrastructure you use.
|
||||
The OOP-style handling breaks this principle, therefore I want to stop
|
||||
promoting it.
|
||||
promoting it.
|
||||
|
||||
@@ -29,6 +29,7 @@ abstract class AbstractAdapter implements AdapterInterface
|
||||
|
||||
if ($prefix === '') {
|
||||
$this->pathPrefix = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,6 +67,6 @@ abstract class AbstractAdapter implements AdapterInterface
|
||||
*/
|
||||
public function removePathPrefix($path)
|
||||
{
|
||||
return substr($path, strlen($this->getPathPrefix()));
|
||||
return substr($path, strlen((string) $this->getPathPrefix()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,13 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
*/
|
||||
protected $safeStorage;
|
||||
|
||||
/**
|
||||
* True to enable timestamps for FTP servers that return unix-style listings.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $enableTimestampsOnUnixListings = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -309,6 +316,20 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* True to enable timestamps for FTP servers that return unix-style listings.
|
||||
*
|
||||
* @param bool $bool
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEnableTimestampsOnUnixListings($bool = false)
|
||||
{
|
||||
$this->enableTimestampsOnUnixListings = $bool;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -389,6 +410,18 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
/**
|
||||
* Normalize a Unix file entry.
|
||||
*
|
||||
* Given $item contains:
|
||||
* '-rw-r--r-- 1 ftp ftp 409 Aug 19 09:01 file1.txt'
|
||||
*
|
||||
* This function will return:
|
||||
* [
|
||||
* 'type' => 'file',
|
||||
* 'path' => 'file1.txt',
|
||||
* 'visibility' => 'public',
|
||||
* 'size' => 409,
|
||||
* 'timestamp' => 1566205260
|
||||
* ]
|
||||
*
|
||||
* @param string $item
|
||||
* @param string $base
|
||||
*
|
||||
@@ -402,19 +435,62 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
throw new RuntimeException("Metadata can't be parsed from item '$item' , not enough parts.");
|
||||
}
|
||||
|
||||
list($permissions, /* $number */, /* $owner */, /* $group */, $size, /* $month */, /* $day */, /* $time*/, $name) = explode(' ', $item, 9);
|
||||
list($permissions, /* $number */, /* $owner */, /* $group */, $size, $month, $day, $timeOrYear, $name) = explode(' ', $item, 9);
|
||||
$type = $this->detectType($permissions);
|
||||
$path = $base === '' ? $name : $base . $this->separator . $name;
|
||||
|
||||
if ($type === 'dir') {
|
||||
return compact('type', 'path');
|
||||
$result = compact('type', 'path');
|
||||
if ($this->enableTimestampsOnUnixListings) {
|
||||
$timestamp = $this->normalizeUnixTimestamp($month, $day, $timeOrYear);
|
||||
$result += compact('timestamp');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$permissions = $this->normalizePermissions($permissions);
|
||||
$visibility = $permissions & 0044 ? AdapterInterface::VISIBILITY_PUBLIC : AdapterInterface::VISIBILITY_PRIVATE;
|
||||
$size = (int) $size;
|
||||
|
||||
return compact('type', 'path', 'visibility', 'size');
|
||||
$result = compact('type', 'path', 'visibility', 'size');
|
||||
if ($this->enableTimestampsOnUnixListings) {
|
||||
$timestamp = $this->normalizeUnixTimestamp($month, $day, $timeOrYear);
|
||||
$result += compact('timestamp');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only accurate to the minute (current year), or to the day.
|
||||
*
|
||||
* Inadequacies in timestamp accuracy are due to limitations of the FTP 'LIST' command
|
||||
*
|
||||
* Note: The 'MLSD' command is a machine-readable replacement for 'LIST'
|
||||
* but many FTP servers do not support it :(
|
||||
*
|
||||
* @param string $month e.g. 'Aug'
|
||||
* @param string $day e.g. '19'
|
||||
* @param string $timeOrYear e.g. '09:01' OR '2015'
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function normalizeUnixTimestamp($month, $day, $timeOrYear)
|
||||
{
|
||||
if (is_numeric($timeOrYear)) {
|
||||
$year = $timeOrYear;
|
||||
$hour = '00';
|
||||
$minute = '00';
|
||||
$seconds = '00';
|
||||
} else {
|
||||
$year = date('Y');
|
||||
list($hour, $minute) = explode(':', $timeOrYear);
|
||||
$seconds = '00';
|
||||
}
|
||||
$dateTime = DateTime::createFromFormat('Y-M-j-G:i:s', "{$year}-{$month}-{$day}-{$hour}:{$minute}:{$seconds}");
|
||||
|
||||
return $dateTime->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -463,7 +539,7 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
*/
|
||||
protected function detectSystemType($item)
|
||||
{
|
||||
return preg_match('/^[0-9]{2,4}-[0-9]{2}-[0-9]{2}/', $item) ? 'windows' : 'unix';
|
||||
return preg_match('/^[0-9]{2,4}-[0-9]{2}-[0-9]{2}/', trim($item)) ? 'windows' : 'unix';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,6 +563,10 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
*/
|
||||
protected function normalizePermissions($permissions)
|
||||
{
|
||||
if (is_numeric($permissions)) {
|
||||
return ((int) $permissions) & 0777;
|
||||
}
|
||||
|
||||
// remove the type identifier
|
||||
$permissions = substr($permissions, 1);
|
||||
|
||||
@@ -565,10 +645,7 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
*/
|
||||
public function getConnection()
|
||||
{
|
||||
$tries = 0;
|
||||
|
||||
while ( ! $this->isConnected() && $tries < 3) {
|
||||
$tries++;
|
||||
if ( ! $this->isConnected()) {
|
||||
$this->disconnect();
|
||||
$this->connect();
|
||||
}
|
||||
@@ -620,4 +697,9 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function isConnected();
|
||||
|
||||
protected function escapePath($path)
|
||||
{
|
||||
return str_replace(['*', '[', ']'], ['\\*', '\\[', '\\]'], $path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
namespace League\Flysystem\Adapter;
|
||||
|
||||
/**
|
||||
* Adapters that implement this interface let the Filesystem know that it files can be overwritten using the write
|
||||
* Adapters that implement this interface let the Filesystem know that files can be overwritten using the write
|
||||
* functions and don't need the update function to be called. This can help improve performance when asserts are disabled.
|
||||
*/
|
||||
interface CanOverwriteFiles {}
|
||||
interface CanOverwriteFiles
|
||||
{
|
||||
}
|
||||
|
||||
86
vendor/league/flysystem/src/Adapter/Ftp.php
vendored
86
vendor/league/flysystem/src/Adapter/Ftp.php
vendored
@@ -2,13 +2,16 @@
|
||||
|
||||
namespace League\Flysystem\Adapter;
|
||||
|
||||
use ErrorException;
|
||||
use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait;
|
||||
use League\Flysystem\AdapterInterface;
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\ConnectionErrorException;
|
||||
use League\Flysystem\ConnectionRuntimeException;
|
||||
use League\Flysystem\InvalidRootException;
|
||||
use League\Flysystem\Util;
|
||||
use League\Flysystem\Util\MimeType;
|
||||
use RuntimeException;
|
||||
|
||||
use function in_array;
|
||||
|
||||
class Ftp extends AbstractFtpAdapter
|
||||
{
|
||||
@@ -53,6 +56,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
'ignorePassiveAddress',
|
||||
'recurseManually',
|
||||
'utf8',
|
||||
'enableTimestampsOnUnixListings',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -127,14 +131,21 @@ class Ftp extends AbstractFtpAdapter
|
||||
*/
|
||||
public function connect()
|
||||
{
|
||||
$tries = 3;
|
||||
start_connecting:
|
||||
|
||||
if ($this->ssl) {
|
||||
$this->connection = ftp_ssl_connect($this->getHost(), $this->getPort(), $this->getTimeout());
|
||||
$this->connection = @ftp_ssl_connect($this->getHost(), $this->getPort(), $this->getTimeout());
|
||||
} else {
|
||||
$this->connection = ftp_connect($this->getHost(), $this->getPort(), $this->getTimeout());
|
||||
$this->connection = @ftp_connect($this->getHost(), $this->getPort(), $this->getTimeout());
|
||||
}
|
||||
|
||||
if ( ! $this->connection) {
|
||||
throw new RuntimeException('Could not connect to host: ' . $this->getHost() . ', port:' . $this->getPort());
|
||||
$tries--;
|
||||
|
||||
if ($tries > 0) goto start_connecting;
|
||||
|
||||
throw new ConnectionRuntimeException('Could not connect to host: ' . $this->getHost() . ', port:' . $this->getPort());
|
||||
}
|
||||
|
||||
$this->login();
|
||||
@@ -151,8 +162,8 @@ class Ftp extends AbstractFtpAdapter
|
||||
{
|
||||
if ($this->utf8) {
|
||||
$response = ftp_raw($this->connection, "OPTS UTF8 ON");
|
||||
if (substr($response[0], 0, 3) !== '200') {
|
||||
throw new RuntimeException(
|
||||
if (!in_array(substr($response[0], 0, 3), ['200', '202'])) {
|
||||
throw new ConnectionRuntimeException(
|
||||
'Could not set UTF-8 mode for connection: ' . $this->getHost() . '::' . $this->getPort()
|
||||
);
|
||||
}
|
||||
@@ -162,7 +173,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
/**
|
||||
* Set the connections to passive mode.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws ConnectionRuntimeException
|
||||
*/
|
||||
protected function setConnectionPassiveMode()
|
||||
{
|
||||
@@ -171,7 +182,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
}
|
||||
|
||||
if ( ! ftp_pasv($this->connection, $this->passive)) {
|
||||
throw new RuntimeException(
|
||||
throw new ConnectionRuntimeException(
|
||||
'Could not set passive mode for connection: ' . $this->getHost() . '::' . $this->getPort()
|
||||
);
|
||||
}
|
||||
@@ -186,7 +197,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
$connection = $this->connection;
|
||||
|
||||
if ($root && ! ftp_chdir($connection, $root)) {
|
||||
throw new RuntimeException('Root is invalid or does not exist: ' . $this->getRoot());
|
||||
throw new InvalidRootException('Root is invalid or does not exist: ' . $this->getRoot());
|
||||
}
|
||||
|
||||
// Store absolute path for further reference.
|
||||
@@ -199,11 +210,12 @@ class Ftp extends AbstractFtpAdapter
|
||||
/**
|
||||
* Login.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws ConnectionRuntimeException
|
||||
*/
|
||||
protected function login()
|
||||
{
|
||||
set_error_handler(function () {});
|
||||
set_error_handler(function () {
|
||||
});
|
||||
$isLoggedIn = ftp_login(
|
||||
$this->connection,
|
||||
$this->getUsername(),
|
||||
@@ -213,7 +225,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
|
||||
if ( ! $isLoggedIn) {
|
||||
$this->disconnect();
|
||||
throw new RuntimeException(
|
||||
throw new ConnectionRuntimeException(
|
||||
'Could not login with connection: ' . $this->getHost() . '::' . $this->getPort(
|
||||
) . ', username: ' . $this->getUsername()
|
||||
);
|
||||
@@ -225,8 +237,8 @@ class Ftp extends AbstractFtpAdapter
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
if (is_resource($this->connection)) {
|
||||
ftp_close($this->connection);
|
||||
if ($this->hasFtpConnection()) {
|
||||
@ftp_close($this->connection);
|
||||
}
|
||||
|
||||
$this->connection = null;
|
||||
@@ -248,7 +260,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
}
|
||||
|
||||
$result['contents'] = $contents;
|
||||
$result['mimetype'] = Util::guessMimeType($path, $contents);
|
||||
$result['mimetype'] = $config->get('mimetype') ?: Util::guessMimeType($path, $contents);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -380,19 +392,17 @@ class Ftp extends AbstractFtpAdapter
|
||||
*/
|
||||
public function getMetadata($path)
|
||||
{
|
||||
$connection = $this->getConnection();
|
||||
|
||||
if ($path === '') {
|
||||
return ['type' => 'dir', 'path' => ''];
|
||||
}
|
||||
|
||||
if (@ftp_chdir($connection, $path) === true) {
|
||||
if (@ftp_chdir($this->getConnection(), $path) === true) {
|
||||
$this->setConnectionRoot();
|
||||
|
||||
return ['type' => 'dir', 'path' => $path];
|
||||
}
|
||||
|
||||
$listing = $this->ftpRawlist('-A', str_replace('*', '\\*', $path));
|
||||
$listing = $this->ftpRawlist('-A', $path);
|
||||
|
||||
if (empty($listing) || in_array('total 0', $listing, true)) {
|
||||
return false;
|
||||
@@ -488,8 +498,6 @@ class Ftp extends AbstractFtpAdapter
|
||||
*/
|
||||
protected function listDirectoryContents($directory, $recursive = true)
|
||||
{
|
||||
$directory = str_replace('*', '\\*', $directory);
|
||||
|
||||
if ($recursive && $this->recurseManually) {
|
||||
return $this->listDirectoryContentsRecursive($directory);
|
||||
}
|
||||
@@ -512,7 +520,9 @@ class Ftp extends AbstractFtpAdapter
|
||||
|
||||
foreach ($listing as $item) {
|
||||
$output[] = $item;
|
||||
if ($item['type'] !== 'dir') continue;
|
||||
if ($item['type'] !== 'dir') {
|
||||
continue;
|
||||
}
|
||||
$output = array_merge($output, $this->listDirectoryContentsRecursive($item['path']));
|
||||
}
|
||||
|
||||
@@ -523,19 +533,12 @@ class Ftp extends AbstractFtpAdapter
|
||||
* Check if the connection is open.
|
||||
*
|
||||
* @return bool
|
||||
* @throws ErrorException
|
||||
*
|
||||
* @throws ConnectionErrorException
|
||||
*/
|
||||
public function isConnected()
|
||||
{
|
||||
try {
|
||||
return is_resource($this->connection) && ftp_rawlist($this->connection, $this->getRoot()) !== false;
|
||||
} catch (ErrorException $e) {
|
||||
if (strpos($e->getMessage(), 'ftp_rawlist') === false) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return $this->hasFtpConnection() && $this->getRawExecResponseCode('NOOP') === 200;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -561,8 +564,21 @@ class Ftp extends AbstractFtpAdapter
|
||||
$connection = $this->getConnection();
|
||||
|
||||
if ($this->isPureFtpd) {
|
||||
$path = str_replace(' ', '\ ', $path);
|
||||
$path = str_replace([' ', '[', ']'], ['\ ', '\\[', '\\]'], $path);
|
||||
}
|
||||
return ftp_rawlist($connection, $options . ' ' . $path);
|
||||
|
||||
return ftp_rawlist($connection, $options . ' ' . $this->escapePath($path));
|
||||
}
|
||||
|
||||
private function getRawExecResponseCode($command)
|
||||
{
|
||||
$response = @ftp_raw($this->connection, trim($command)) ?: [];
|
||||
|
||||
return (int) preg_replace('/\D/', '', implode(' ', (array) $response));
|
||||
}
|
||||
|
||||
private function hasFtpConnection(): bool
|
||||
{
|
||||
return is_resource($this->connection) || $this->connection instanceof \FTP\Connection;
|
||||
}
|
||||
}
|
||||
|
||||
12
vendor/league/flysystem/src/Adapter/Ftpd.php
vendored
12
vendor/league/flysystem/src/Adapter/Ftpd.php
vendored
@@ -13,7 +13,15 @@ class Ftpd extends Ftp
|
||||
return ['type' => 'dir', 'path' => ''];
|
||||
}
|
||||
|
||||
if ( ! ($object = ftp_raw($this->getConnection(), 'STAT ' . $path)) || count($object) < 3) {
|
||||
if (@ftp_chdir($this->getConnection(), $path) === true) {
|
||||
$this->setConnectionRoot();
|
||||
|
||||
return ['type' => 'dir', 'path' => $path];
|
||||
}
|
||||
|
||||
$object = ftp_raw($this->getConnection(), 'STAT ' . $this->escapePath($path));
|
||||
|
||||
if ( ! $object || count($object) < 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -29,7 +37,7 @@ class Ftpd extends Ftp
|
||||
*/
|
||||
protected function listDirectoryContents($directory, $recursive = true)
|
||||
{
|
||||
$listing = ftp_rawlist($this->getConnection(), $directory, $recursive);
|
||||
$listing = ftp_rawlist($this->getConnection(), $this->escapePath($directory), $recursive);
|
||||
|
||||
if ($listing === false || ( ! empty($listing) && substr($listing[0], 0, 5) === "ftpd:")) {
|
||||
return [];
|
||||
|
||||
42
vendor/league/flysystem/src/Adapter/Local.php
vendored
42
vendor/league/flysystem/src/Adapter/Local.php
vendored
@@ -5,7 +5,6 @@ namespace League\Flysystem\Adapter;
|
||||
use DirectoryIterator;
|
||||
use FilesystemIterator;
|
||||
use finfo as Finfo;
|
||||
use League\Flysystem\AdapterInterface;
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\Exception;
|
||||
use League\Flysystem\NotSupportedException;
|
||||
@@ -33,11 +32,11 @@ class Local extends AbstractAdapter
|
||||
*/
|
||||
protected static $permissions = [
|
||||
'file' => [
|
||||
'public' => 0644,
|
||||
'public' => 0644,
|
||||
'private' => 0600,
|
||||
],
|
||||
'dir' => [
|
||||
'public' => 0755,
|
||||
'dir' => [
|
||||
'public' => 0755,
|
||||
'private' => 0700,
|
||||
],
|
||||
];
|
||||
@@ -106,6 +105,7 @@ class Local extends AbstractAdapter
|
||||
}
|
||||
|
||||
umask($umask);
|
||||
clearstatcache(false, $root);
|
||||
|
||||
if ( ! is_dir($root)) {
|
||||
$errorMessage = isset($mkdirError['message']) ? $mkdirError['message'] : '';
|
||||
@@ -206,8 +206,9 @@ class Local extends AbstractAdapter
|
||||
|
||||
$result = compact('type', 'path', 'size', 'contents');
|
||||
|
||||
if ($mimetype = Util::guessMimeType($path, $contents)) {
|
||||
$result['mimetype'] = $mimetype;
|
||||
if ($visibility = $config->get('visibility')) {
|
||||
$this->setVisibility($path, $visibility);
|
||||
$result['visibility'] = $visibility;
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -219,7 +220,7 @@ class Local extends AbstractAdapter
|
||||
public function read($path)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$contents = file_get_contents($location);
|
||||
$contents = @file_get_contents($location);
|
||||
|
||||
if ($contents === false) {
|
||||
return false;
|
||||
@@ -287,6 +288,8 @@ class Local extends AbstractAdapter
|
||||
$result[] = $this->normalizeFileInfo($file);
|
||||
}
|
||||
|
||||
unset($iterator);
|
||||
|
||||
return array_filter($result);
|
||||
}
|
||||
|
||||
@@ -296,6 +299,7 @@ class Local extends AbstractAdapter
|
||||
public function getMetadata($path)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
clearstatcache(false, $location);
|
||||
$info = new SplFileInfo($location);
|
||||
|
||||
return $this->normalizeFileInfo($info);
|
||||
@@ -318,7 +322,7 @@ class Local extends AbstractAdapter
|
||||
$finfo = new Finfo(FILEINFO_MIME_TYPE);
|
||||
$mimetype = $finfo->file($location);
|
||||
|
||||
if (in_array($mimetype, ['application/octet-stream', 'inode/x-empty'])) {
|
||||
if (in_array($mimetype, ['application/octet-stream', 'inode/x-empty', 'application/x-empty'])) {
|
||||
$mimetype = Util\MimeType::detectByFilename($location);
|
||||
}
|
||||
|
||||
@@ -341,7 +345,15 @@ class Local extends AbstractAdapter
|
||||
$location = $this->applyPathPrefix($path);
|
||||
clearstatcache(false, $location);
|
||||
$permissions = octdec(substr(sprintf('%o', fileperms($location)), -4));
|
||||
$visibility = $permissions & 0044 ? AdapterInterface::VISIBILITY_PUBLIC : AdapterInterface::VISIBILITY_PRIVATE;
|
||||
$type = is_dir($location) ? 'dir' : 'file';
|
||||
|
||||
foreach ($this->permissionMap[$type] as $visibility => $visibilityPermissions) {
|
||||
if ($visibilityPermissions == $permissions) {
|
||||
return compact('path', 'visibility');
|
||||
}
|
||||
}
|
||||
|
||||
$visibility = substr(sprintf('%o', fileperms($location)), -4);
|
||||
|
||||
return compact('path', 'visibility');
|
||||
}
|
||||
@@ -370,11 +382,13 @@ class Local extends AbstractAdapter
|
||||
$location = $this->applyPathPrefix($dirname);
|
||||
$umask = umask(0);
|
||||
$visibility = $config->get('visibility', 'public');
|
||||
$return = ['path' => $dirname, 'type' => 'dir'];
|
||||
|
||||
if ( ! is_dir($location) && ! mkdir($location, $this->permissionMap['dir'][$visibility], true)) {
|
||||
$return = false;
|
||||
} else {
|
||||
$return = ['path' => $dirname, 'type' => 'dir'];
|
||||
if ( ! is_dir($location)) {
|
||||
if (false === @mkdir($location, $this->permissionMap['dir'][$visibility], true)
|
||||
|| false === is_dir($location)) {
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
|
||||
umask($umask);
|
||||
@@ -401,6 +415,8 @@ class Local extends AbstractAdapter
|
||||
$this->deleteFileInfoObject($file);
|
||||
}
|
||||
|
||||
unset($contents);
|
||||
|
||||
return rmdir($location);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,15 +34,17 @@ trait StreamedCopyTrait
|
||||
// Required abstract method
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $path
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
abstract public function readStream($path);
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param resource $resource
|
||||
* @param Config $config
|
||||
* @param string $path
|
||||
* @param resource $resource
|
||||
* @param Config $config
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
abstract public function writeStream($path, $resource, Config $config);
|
||||
|
||||
2
vendor/league/flysystem/src/Config.php
vendored
2
vendor/league/flysystem/src/Config.php
vendored
@@ -10,7 +10,7 @@ class Config
|
||||
protected $settings = [];
|
||||
|
||||
/**
|
||||
* @var Config
|
||||
* @var Config|null
|
||||
*/
|
||||
protected $fallback;
|
||||
|
||||
|
||||
9
vendor/league/flysystem/src/ConnectionErrorException.php
vendored
Normal file
9
vendor/league/flysystem/src/ConnectionErrorException.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use ErrorException;
|
||||
|
||||
class ConnectionErrorException extends ErrorException implements FilesystemException
|
||||
{
|
||||
}
|
||||
9
vendor/league/flysystem/src/ConnectionRuntimeException.php
vendored
Normal file
9
vendor/league/flysystem/src/ConnectionRuntimeException.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class ConnectionRuntimeException extends RuntimeException implements FilesystemException
|
||||
{
|
||||
}
|
||||
17
vendor/league/flysystem/src/CorruptedPathDetected.php
vendored
Normal file
17
vendor/league/flysystem/src/CorruptedPathDetected.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use LogicException;
|
||||
|
||||
class CorruptedPathDetected extends LogicException implements FilesystemException
|
||||
{
|
||||
/**
|
||||
* @param string $path
|
||||
* @return CorruptedPathDetected
|
||||
*/
|
||||
public static function forPath($path)
|
||||
{
|
||||
return new CorruptedPathDetected("Corrupted path detected: " . $path);
|
||||
}
|
||||
}
|
||||
2
vendor/league/flysystem/src/Exception.php
vendored
2
vendor/league/flysystem/src/Exception.php
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
class Exception extends \Exception
|
||||
class Exception extends \Exception implements FilesystemException
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
28
vendor/league/flysystem/src/Filesystem.php
vendored
28
vendor/league/flysystem/src/Filesystem.php
vendored
@@ -8,12 +8,13 @@ use League\Flysystem\Plugin\PluggableTrait;
|
||||
use League\Flysystem\Util\ContentListingFormatter;
|
||||
|
||||
/**
|
||||
* @method array getWithMetadata(string $path, array $metadata)
|
||||
* @method bool forceCopy(string $path, string $newpath)
|
||||
* @method bool forceRename(string $path, string $newpath)
|
||||
* @method array listFiles(string $path = '', boolean $recursive = false)
|
||||
* @method array listPaths(string $path = '', boolean $recursive = false)
|
||||
* @method array listWith(array $keys = [], $directory = '', $recursive = false)
|
||||
* @method void emptyDir(string $dirname)
|
||||
* @method array|false getWithMetadata(string $path, string[] $metadata)
|
||||
* @method bool forceCopy(string $path, string $newpath)
|
||||
* @method bool forceRename(string $path, string $newpath)
|
||||
* @method array listFiles(string $path = '', boolean $recursive = false)
|
||||
* @method string[] listPaths(string $path = '', boolean $recursive = false)
|
||||
* @method array listWith(string[] $keys = [], $directory = '', $recursive = false)
|
||||
*/
|
||||
class Filesystem implements FilesystemInterface
|
||||
{
|
||||
@@ -74,7 +75,7 @@ class Filesystem implements FilesystemInterface
|
||||
*/
|
||||
public function writeStream($path, $resource, array $config = [])
|
||||
{
|
||||
if ( ! is_resource($resource)) {
|
||||
if ( ! is_resource($resource) || get_resource_type($resource) !== 'stream') {
|
||||
throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ class Filesystem implements FilesystemInterface
|
||||
*/
|
||||
public function putStream($path, $resource, array $config = [])
|
||||
{
|
||||
if ( ! is_resource($resource)) {
|
||||
if ( ! is_resource($resource) || get_resource_type($resource) !== 'stream') {
|
||||
throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@ class Filesystem implements FilesystemInterface
|
||||
$config = $this->prepareConfig($config);
|
||||
Util::rewindStream($resource);
|
||||
|
||||
if ( ! $this->getAdapter() instanceof CanOverwriteFiles &&$this->has($path)) {
|
||||
if ( ! $this->getAdapter() instanceof CanOverwriteFiles && $this->has($path)) {
|
||||
return (bool) $this->getAdapter()->updateStream($path, $resource, $config);
|
||||
}
|
||||
|
||||
@@ -158,7 +159,7 @@ class Filesystem implements FilesystemInterface
|
||||
*/
|
||||
public function updateStream($path, $resource, array $config = [])
|
||||
{
|
||||
if ( ! is_resource($resource)) {
|
||||
if ( ! is_resource($resource) || get_resource_type($resource) !== 'stream') {
|
||||
throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
|
||||
}
|
||||
|
||||
@@ -270,7 +271,8 @@ class Filesystem implements FilesystemInterface
|
||||
$directory = Util::normalizePath($directory);
|
||||
$contents = $this->getAdapter()->listContents($directory, $recursive);
|
||||
|
||||
return (new ContentListingFormatter($directory, $recursive))->formatListing($contents);
|
||||
return (new ContentListingFormatter($directory, $recursive, $this->config->get('case_sensitive', true)))
|
||||
->formatListing($contents);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,7 +302,7 @@ class Filesystem implements FilesystemInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
return $object['timestamp'];
|
||||
return (int) $object['timestamp'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,7 +366,7 @@ class Filesystem implements FilesystemInterface
|
||||
|
||||
if ( ! $handler) {
|
||||
$metadata = $this->getMetadata($path);
|
||||
$handler = $metadata['type'] === 'file' ? new File($this, $path) : new Directory($this, $path);
|
||||
$handler = ($metadata && $metadata['type'] === 'file') ? new File($this, $path) : new Directory($this, $path);
|
||||
}
|
||||
|
||||
$handler->setPath($path);
|
||||
|
||||
7
vendor/league/flysystem/src/FilesystemException.php
vendored
Normal file
7
vendor/league/flysystem/src/FilesystemException.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
interface FilesystemException
|
||||
{
|
||||
}
|
||||
@@ -87,7 +87,7 @@ interface FilesystemInterface
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return string|false The timestamp or false on failure.
|
||||
* @return int|false The timestamp or false on failure.
|
||||
*/
|
||||
public function getTimestamp($path);
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@ use LogicException;
|
||||
/**
|
||||
* Thrown when the MountManager cannot find a filesystem.
|
||||
*/
|
||||
class FilesystemNotFoundException extends LogicException
|
||||
class FilesystemNotFoundException extends LogicException implements FilesystemException
|
||||
{
|
||||
}
|
||||
|
||||
2
vendor/league/flysystem/src/Handler.php
vendored
2
vendor/league/flysystem/src/Handler.php
vendored
@@ -60,7 +60,7 @@ abstract class Handler
|
||||
{
|
||||
$metadata = $this->filesystem->getMetadata($this->path);
|
||||
|
||||
return $metadata['type'];
|
||||
return $metadata ? $metadata['type'] : 'dir';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
9
vendor/league/flysystem/src/InvalidRootException.php
vendored
Normal file
9
vendor/league/flysystem/src/InvalidRootException.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class InvalidRootException extends RuntimeException implements FilesystemException
|
||||
{
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace League\Flysystem;
|
||||
use RuntimeException;
|
||||
use SplFileInfo;
|
||||
|
||||
class NotSupportedException extends RuntimeException
|
||||
class NotSupportedException extends RuntimeException implements FilesystemException
|
||||
{
|
||||
/**
|
||||
* Create a new exception for a link.
|
||||
|
||||
@@ -20,8 +20,8 @@ class GetWithMetadata extends AbstractPlugin
|
||||
/**
|
||||
* Get metadata for an object with required metadata.
|
||||
*
|
||||
* @param string $path path to file
|
||||
* @param array $metadata metadata keys
|
||||
* @param string $path path to file
|
||||
* @param string[] $metadata metadata keys
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws FileNotFoundException
|
||||
|
||||
@@ -20,7 +20,7 @@ class ListPaths extends AbstractPlugin
|
||||
* @param string $directory
|
||||
* @param bool $recursive
|
||||
*
|
||||
* @return array paths
|
||||
* @return string[] paths
|
||||
*/
|
||||
public function handle($directory = '', $recursive = false)
|
||||
{
|
||||
|
||||
@@ -17,9 +17,9 @@ class ListWith extends AbstractPlugin
|
||||
/**
|
||||
* List contents with metadata.
|
||||
*
|
||||
* @param array $keys
|
||||
* @param string $directory
|
||||
* @param bool $recursive
|
||||
* @param string[] $keys
|
||||
* @param string $directory
|
||||
* @param bool $recursive
|
||||
*
|
||||
* @return array listing with metadata
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace League\Flysystem;
|
||||
|
||||
use LogicException;
|
||||
|
||||
class RootViolationException extends LogicException
|
||||
class RootViolationException extends LogicException implements FilesystemException
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
34
vendor/league/flysystem/src/Util.php
vendored
34
vendor/league/flysystem/src/Util.php
vendored
@@ -5,6 +5,8 @@ namespace League\Flysystem;
|
||||
use League\Flysystem\Util\MimeType;
|
||||
use LogicException;
|
||||
|
||||
use function strcmp;
|
||||
|
||||
class Util
|
||||
{
|
||||
/**
|
||||
@@ -102,8 +104,7 @@ class Util
|
||||
public static function normalizeRelativePath($path)
|
||||
{
|
||||
$path = str_replace('\\', '/', $path);
|
||||
$path = static::removeFunkyWhiteSpace($path);
|
||||
|
||||
$path = static::removeFunkyWhiteSpace($path);
|
||||
$parts = [];
|
||||
|
||||
foreach (explode('/', $path) as $part) {
|
||||
@@ -127,21 +128,22 @@ class Util
|
||||
}
|
||||
}
|
||||
|
||||
return implode('/', $parts);
|
||||
$path = implode('/', $parts);
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes unprintable characters and invalid unicode characters.
|
||||
* Rejects unprintable characters and invalid unicode characters.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return string $path
|
||||
*/
|
||||
protected static function removeFunkyWhiteSpace($path) {
|
||||
// We do this check in a loop, since removing invalid unicode characters
|
||||
// can lead to new characters being created.
|
||||
while (preg_match('#\p{C}+|^\./#u', $path)) {
|
||||
$path = preg_replace('#\p{C}+|^\./#u', '', $path);
|
||||
protected static function removeFunkyWhiteSpace($path)
|
||||
{
|
||||
if (preg_match('#\p{C}+#u', $path)) {
|
||||
throw CorruptedPathDetected::forPath($path);
|
||||
}
|
||||
|
||||
return $path;
|
||||
@@ -175,7 +177,7 @@ class Util
|
||||
/**
|
||||
* Guess MIME Type based on the path of the file and it's content.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $path
|
||||
* @param string|resource $content
|
||||
*
|
||||
* @return string|null MIME Type or NULL if no extension detected
|
||||
@@ -204,7 +206,7 @@ class Util
|
||||
$listedDirectories = [];
|
||||
|
||||
foreach ($listing as $object) {
|
||||
list($directories, $listedDirectories) = static::emulateObjectDirectories($object, $directories, $listedDirectories);
|
||||
[$directories, $listedDirectories] = static::emulateObjectDirectories($object, $directories, $listedDirectories);
|
||||
}
|
||||
|
||||
$directories = array_diff(array_unique($directories), array_unique($listedDirectories));
|
||||
@@ -266,12 +268,16 @@ class Util
|
||||
*
|
||||
* @param resource $resource
|
||||
*
|
||||
* @return int stream size
|
||||
* @return int|null stream size
|
||||
*/
|
||||
public static function getStreamSize($resource)
|
||||
{
|
||||
$stat = fstat($resource);
|
||||
|
||||
if ( ! is_array($stat) || ! isset($stat['size'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $stat['size'];
|
||||
}
|
||||
|
||||
@@ -290,13 +296,13 @@ class Util
|
||||
$listedDirectories[] = $object['path'];
|
||||
}
|
||||
|
||||
if (empty($object['dirname'])) {
|
||||
if ( ! isset($object['dirname']) || trim($object['dirname']) === '') {
|
||||
return [$directories, $listedDirectories];
|
||||
}
|
||||
|
||||
$parent = $object['dirname'];
|
||||
|
||||
while ( ! empty($parent) && ! in_array($parent, $directories)) {
|
||||
while (isset($parent) && trim($parent) !== '' && ! in_array($parent, $directories)) {
|
||||
$directories[] = $parent;
|
||||
$parent = static::dirname($parent);
|
||||
}
|
||||
|
||||
@@ -13,19 +13,26 @@ class ContentListingFormatter
|
||||
* @var string
|
||||
*/
|
||||
private $directory;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $recursive;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $caseSensitive;
|
||||
|
||||
/**
|
||||
* @param string $directory
|
||||
* @param bool $recursive
|
||||
*/
|
||||
public function __construct($directory, $recursive)
|
||||
public function __construct($directory, $recursive, $caseSensitive = true)
|
||||
{
|
||||
$this->directory = $directory;
|
||||
$this->directory = rtrim($directory, '/');
|
||||
$this->recursive = $recursive;
|
||||
$this->caseSensitive = $caseSensitive;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,14 +44,9 @@ class ContentListingFormatter
|
||||
*/
|
||||
public function formatListing(array $listing)
|
||||
{
|
||||
$listing = array_values(
|
||||
array_map(
|
||||
[$this, 'addPathInfo'],
|
||||
array_filter($listing, [$this, 'isEntryOutOfScope'])
|
||||
)
|
||||
);
|
||||
$listing = array_filter(array_map([$this, 'addPathInfo'], $listing), [$this, 'isEntryOutOfScope']);
|
||||
|
||||
return $this->sortListing($listing);
|
||||
return $this->sortListing(array_values($listing));
|
||||
}
|
||||
|
||||
private function addPathInfo(array $entry)
|
||||
@@ -85,7 +87,9 @@ class ContentListingFormatter
|
||||
return true;
|
||||
}
|
||||
|
||||
return strpos($entry['path'], $this->directory . '/') === 0;
|
||||
return $this->caseSensitive
|
||||
? strpos($entry['path'], $this->directory . '/') === 0
|
||||
: stripos($entry['path'], $this->directory . '/') === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +101,9 @@ class ContentListingFormatter
|
||||
*/
|
||||
private function isDirectChild(array $entry)
|
||||
{
|
||||
return Util::dirname($entry['path']) === $this->directory;
|
||||
return $this->caseSensitive
|
||||
? $entry['dirname'] === $this->directory
|
||||
: strcasecmp($this->directory, $entry['dirname']) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
212
vendor/league/flysystem/src/Util/MimeType.php
vendored
212
vendor/league/flysystem/src/Util/MimeType.php
vendored
@@ -2,220 +2,72 @@
|
||||
|
||||
namespace League\Flysystem\Util;
|
||||
|
||||
use finfo;
|
||||
use ErrorException;
|
||||
use League\MimeTypeDetection\FinfoMimeTypeDetector;
|
||||
use League\MimeTypeDetection\GeneratedExtensionToMimeTypeMap;
|
||||
use League\MimeTypeDetection\MimeTypeDetector;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class MimeType
|
||||
{
|
||||
protected static $extensionToMimeTypeMap = [
|
||||
'hqx' => 'application/mac-binhex40',
|
||||
'cpt' => 'application/mac-compactpro',
|
||||
'csv' => 'text/x-comma-separated-values',
|
||||
'bin' => 'application/octet-stream',
|
||||
'dms' => 'application/octet-stream',
|
||||
'lha' => 'application/octet-stream',
|
||||
'lzh' => 'application/octet-stream',
|
||||
'exe' => 'application/octet-stream',
|
||||
'class' => 'application/octet-stream',
|
||||
'psd' => 'application/x-photoshop',
|
||||
'so' => 'application/octet-stream',
|
||||
'sea' => 'application/octet-stream',
|
||||
'dll' => 'application/octet-stream',
|
||||
'oda' => 'application/oda',
|
||||
'pdf' => 'application/pdf',
|
||||
'ai' => 'application/pdf',
|
||||
'eps' => 'application/postscript',
|
||||
'epub' => 'application/epub+zip',
|
||||
'ps' => 'application/postscript',
|
||||
'smi' => 'application/smil',
|
||||
'smil' => 'application/smil',
|
||||
'mif' => 'application/vnd.mif',
|
||||
'xls' => 'application/vnd.ms-excel',
|
||||
'ppt' => 'application/powerpoint',
|
||||
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'wbxml' => 'application/wbxml',
|
||||
'wmlc' => 'application/wmlc',
|
||||
'dcr' => 'application/x-director',
|
||||
'dir' => 'application/x-director',
|
||||
'dxr' => 'application/x-director',
|
||||
'dvi' => 'application/x-dvi',
|
||||
'gtar' => 'application/x-gtar',
|
||||
'gz' => 'application/x-gzip',
|
||||
'gzip' => 'application/x-gzip',
|
||||
'php' => 'application/x-httpd-php',
|
||||
'php4' => 'application/x-httpd-php',
|
||||
'php3' => 'application/x-httpd-php',
|
||||
'phtml' => 'application/x-httpd-php',
|
||||
'phps' => 'application/x-httpd-php-source',
|
||||
'js' => 'application/javascript',
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'sit' => 'application/x-stuffit',
|
||||
'tar' => 'application/x-tar',
|
||||
'tgz' => 'application/x-tar',
|
||||
'z' => 'application/x-compress',
|
||||
'xhtml' => 'application/xhtml+xml',
|
||||
'xht' => 'application/xhtml+xml',
|
||||
'rdf' => 'application/rdf+xml',
|
||||
'zip' => 'application/x-zip',
|
||||
'rar' => 'application/x-rar',
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'mpga' => 'audio/mpeg',
|
||||
'mp2' => 'audio/mpeg',
|
||||
'mp3' => 'audio/mpeg',
|
||||
'aif' => 'audio/x-aiff',
|
||||
'aiff' => 'audio/x-aiff',
|
||||
'aifc' => 'audio/x-aiff',
|
||||
'ram' => 'audio/x-pn-realaudio',
|
||||
'rm' => 'audio/x-pn-realaudio',
|
||||
'rpm' => 'audio/x-pn-realaudio-plugin',
|
||||
'ra' => 'audio/x-realaudio',
|
||||
'rv' => 'video/vnd.rn-realvideo',
|
||||
'wav' => 'audio/x-wav',
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'jpe' => 'image/jpeg',
|
||||
'png' => 'image/png',
|
||||
'gif' => 'image/gif',
|
||||
'bmp' => 'image/bmp',
|
||||
'tiff' => 'image/tiff',
|
||||
'tif' => 'image/tiff',
|
||||
'svg' => 'image/svg+xml',
|
||||
'css' => 'text/css',
|
||||
'html' => 'text/html',
|
||||
'htm' => 'text/html',
|
||||
'shtml' => 'text/html',
|
||||
'txt' => 'text/plain',
|
||||
'text' => 'text/plain',
|
||||
'log' => 'text/plain',
|
||||
'rtx' => 'text/richtext',
|
||||
'rtf' => 'text/rtf',
|
||||
'xml' => 'application/xml',
|
||||
'xsl' => 'application/xml',
|
||||
'dmn' => 'application/octet-stream',
|
||||
'bpmn' => 'application/octet-stream',
|
||||
'mpeg' => 'video/mpeg',
|
||||
'mpg' => 'video/mpeg',
|
||||
'mpe' => 'video/mpeg',
|
||||
'qt' => 'video/quicktime',
|
||||
'mov' => 'video/quicktime',
|
||||
'avi' => 'video/x-msvideo',
|
||||
'movie' => 'video/x-sgi-movie',
|
||||
'doc' => 'application/msword',
|
||||
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'docm' => 'application/vnd.ms-word.template.macroEnabled.12',
|
||||
'dot' => 'application/msword',
|
||||
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'word' => 'application/msword',
|
||||
'xl' => 'application/excel',
|
||||
'eml' => 'message/rfc822',
|
||||
'json' => 'application/json',
|
||||
'pem' => 'application/x-x509-user-cert',
|
||||
'p10' => 'application/x-pkcs10',
|
||||
'p12' => 'application/x-pkcs12',
|
||||
'p7a' => 'application/x-pkcs7-signature',
|
||||
'p7c' => 'application/pkcs7-mime',
|
||||
'p7m' => 'application/pkcs7-mime',
|
||||
'p7r' => 'application/x-pkcs7-certreqresp',
|
||||
'p7s' => 'application/pkcs7-signature',
|
||||
'crt' => 'application/x-x509-ca-cert',
|
||||
'crl' => 'application/pkix-crl',
|
||||
'der' => 'application/x-x509-ca-cert',
|
||||
'kdb' => 'application/octet-stream',
|
||||
'pgp' => 'application/pgp',
|
||||
'gpg' => 'application/gpg-keys',
|
||||
'sst' => 'application/octet-stream',
|
||||
'csr' => 'application/octet-stream',
|
||||
'rsa' => 'application/x-pkcs7',
|
||||
'cer' => 'application/pkix-cert',
|
||||
'3g2' => 'video/3gpp2',
|
||||
'3gp' => 'video/3gp',
|
||||
'mp4' => 'video/mp4',
|
||||
'm4a' => 'audio/x-m4a',
|
||||
'f4v' => 'video/mp4',
|
||||
'webm' => 'video/webm',
|
||||
'aac' => 'audio/x-acc',
|
||||
'm4u' => 'application/vnd.mpegurl',
|
||||
'm3u' => 'text/plain',
|
||||
'xspf' => 'application/xspf+xml',
|
||||
'vlc' => 'application/videolan',
|
||||
'wmv' => 'video/x-ms-wmv',
|
||||
'au' => 'audio/x-au',
|
||||
'ac3' => 'audio/ac3',
|
||||
'flac' => 'audio/x-flac',
|
||||
'ogg' => 'audio/ogg',
|
||||
'kmz' => 'application/vnd.google-earth.kmz',
|
||||
'kml' => 'application/vnd.google-earth.kml+xml',
|
||||
'ics' => 'text/calendar',
|
||||
'zsh' => 'text/x-scriptzsh',
|
||||
'7zip' => 'application/x-7z-compressed',
|
||||
'cdr' => 'application/cdr',
|
||||
'wma' => 'audio/x-ms-wma',
|
||||
'jar' => 'application/java-archive',
|
||||
'tex' => 'application/x-tex',
|
||||
'latex' => 'application/x-latex',
|
||||
'odt' => 'application/vnd.oasis.opendocument.text',
|
||||
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
||||
'odp' => 'application/vnd.oasis.opendocument.presentation',
|
||||
'odg' => 'application/vnd.oasis.opendocument.graphics',
|
||||
'odc' => 'application/vnd.oasis.opendocument.chart',
|
||||
'odf' => 'application/vnd.oasis.opendocument.formula',
|
||||
'odi' => 'application/vnd.oasis.opendocument.image',
|
||||
'odm' => 'application/vnd.oasis.opendocument.text-master',
|
||||
'odb' => 'application/vnd.oasis.opendocument.database',
|
||||
'ott' => 'application/vnd.oasis.opendocument.text-template',
|
||||
];
|
||||
protected static $extensionToMimeTypeMap = GeneratedExtensionToMimeTypeMap::MIME_TYPES_FOR_EXTENSIONS;
|
||||
protected static $detector;
|
||||
|
||||
public static function useDetector(MimeTypeDetector $detector)
|
||||
{
|
||||
static::$detector = $detector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MimeTypeDetector
|
||||
*/
|
||||
protected static function detector()
|
||||
{
|
||||
if ( ! static::$detector instanceof MimeTypeDetector) {
|
||||
static::$detector = new FinfoMimeTypeDetector();
|
||||
}
|
||||
|
||||
return static::$detector;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Detects MIME Type based on given content.
|
||||
*
|
||||
* @param mixed $content
|
||||
*
|
||||
* @return string|null MIME Type or NULL if no mime type detected
|
||||
* @return string MIME Type
|
||||
*/
|
||||
public static function detectByContent($content)
|
||||
{
|
||||
if ( ! class_exists('finfo') || ! is_string($content)) {
|
||||
return null;
|
||||
if (is_string($content)) {
|
||||
return static::detector()->detectMimeTypeFromBuffer($content);
|
||||
}
|
||||
try {
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
|
||||
return $finfo->buffer($content) ?: null;
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch( ErrorException $e ) {
|
||||
// This is caused by an array to string conversion error.
|
||||
}
|
||||
} // @codeCoverageIgnoreEnd
|
||||
return 'text/plain';
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects MIME Type based on file extension.
|
||||
*
|
||||
* @param string $extension
|
||||
*
|
||||
* @return string|null MIME Type or NULL if no extension detected
|
||||
* @return string MIME Type
|
||||
*/
|
||||
public static function detectByFileExtension($extension)
|
||||
{
|
||||
return isset(static::$extensionToMimeTypeMap[$extension])
|
||||
? static::$extensionToMimeTypeMap[$extension]
|
||||
: 'text/plain';
|
||||
return static::detector()->detectMimeTypeFromPath('artificial.' . $extension) ?: 'text/plain';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string|null MIME Type or NULL if no extension detected
|
||||
* @return string MIME Type
|
||||
*/
|
||||
public static function detectByFilename($filename)
|
||||
{
|
||||
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
return empty($extension) ? 'text/plain' : static::detectByFileExtension($extension);
|
||||
return static::detector()->detectMimeTypeFromPath($filename) ?: 'text/plain';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user