update2
This commit is contained in:
parent
98419bd18d
commit
8a69e45efa
4919 changed files with 28311 additions and 224136 deletions
2
pfosten/vendor/symfony/http-foundation/File/Exception/AccessDeniedException.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/Exception/AccessDeniedException.php
vendored
Executable file → Normal file
|
|
@ -19,8 +19,6 @@ namespace Symfony\Component\HttpFoundation\File\Exception;
|
|||
class AccessDeniedException extends FileException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $path The path to the accessed file
|
||||
*/
|
||||
public function __construct($path)
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/File/Exception/FileException.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/File/Exception/FileException.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/Exception/FileNotFoundException.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/Exception/FileNotFoundException.php
vendored
Executable file → Normal file
|
|
@ -19,8 +19,6 @@ namespace Symfony\Component\HttpFoundation\File\Exception;
|
|||
class FileNotFoundException extends FileException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $path The path to the file that was not found
|
||||
*/
|
||||
public function __construct($path)
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/File/Exception/UnexpectedTypeException.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/Exception/UnexpectedTypeException.php
vendored
Executable file → Normal file
|
|
@ -15,6 +15,6 @@ class UnexpectedTypeException extends FileException
|
|||
{
|
||||
public function __construct($value, $expectedType)
|
||||
{
|
||||
parent::__construct(sprintf('Expected argument of type %s, %s given', $expectedType, is_object($value) ? get_class($value) : gettype($value)));
|
||||
parent::__construct(sprintf('Expected argument of type %s, %s given', $expectedType, \is_object($value) ? \get_class($value) : \gettype($value)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/File/Exception/UploadException.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/File/Exception/UploadException.php
vendored
Executable file → Normal file
12
pfosten/vendor/symfony/http-foundation/File/File.php
vendored
Executable file → Normal file
12
pfosten/vendor/symfony/http-foundation/File/File.php
vendored
Executable file → Normal file
|
|
@ -13,8 +13,8 @@ namespace Symfony\Component\HttpFoundation\File;
|
|||
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
|
||||
|
||||
/**
|
||||
* A file in the file system.
|
||||
|
|
@ -93,9 +93,11 @@ class File extends \SplFileInfo
|
|||
{
|
||||
$target = $this->getTargetFile($directory, $name);
|
||||
|
||||
if (!@rename($this->getPathname(), $target)) {
|
||||
$error = error_get_last();
|
||||
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message'])));
|
||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
||||
$renamed = rename($this->getPathname(), $target);
|
||||
restore_error_handler();
|
||||
if (!$renamed) {
|
||||
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error)));
|
||||
}
|
||||
|
||||
@chmod($target, 0666 & ~umask());
|
||||
|
|
@ -113,7 +115,7 @@ class File extends \SplFileInfo
|
|||
throw new FileException(sprintf('Unable to write in the "%s" directory', $directory));
|
||||
}
|
||||
|
||||
$target = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));
|
||||
$target = rtrim($directory, '/\\').\DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));
|
||||
|
||||
return new self($target, false);
|
||||
}
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesser.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesser.php
vendored
Executable file → Normal file
|
|
@ -65,8 +65,6 @@ class ExtensionGuesser implements ExtensionGuesserInterface
|
|||
* Registers a new extension guesser.
|
||||
*
|
||||
* When guessing, this guesser is preferred over previously registered ones.
|
||||
*
|
||||
* @param ExtensionGuesserInterface $guesser
|
||||
*/
|
||||
public function register(ExtensionGuesserInterface $guesser)
|
||||
{
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesserInterface.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesserInterface.php
vendored
Executable file → Normal file
20
pfosten/vendor/symfony/http-foundation/File/MimeType/FileBinaryMimeTypeGuesser.php
vendored
Executable file → Normal file
20
pfosten/vendor/symfony/http-foundation/File/MimeType/FileBinaryMimeTypeGuesser.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\File\MimeType;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
|
||||
/**
|
||||
* Guesses the mime type with the binary "file" (only available on *nix).
|
||||
|
|
@ -24,8 +24,6 @@ class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
private $cmd;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* The $cmd pattern must contain a "%s" string that will be replaced
|
||||
* with the file name to guess.
|
||||
*
|
||||
|
|
@ -45,7 +43,21 @@ class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return '\\' !== DIRECTORY_SEPARATOR && function_exists('passthru') && function_exists('escapeshellarg');
|
||||
static $supported = null;
|
||||
|
||||
if (null !== $supported) {
|
||||
return $supported;
|
||||
}
|
||||
|
||||
if ('\\' === \DIRECTORY_SEPARATOR || !\function_exists('passthru') || !\function_exists('escapeshellarg')) {
|
||||
return $supported = false;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
passthru('command -v file', $exitStatus);
|
||||
$binPath = trim(ob_get_clean());
|
||||
|
||||
return $supported = 0 === $exitStatus && '' !== $binPath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
6
pfosten/vendor/symfony/http-foundation/File/MimeType/FileinfoMimeTypeGuesser.php
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/http-foundation/File/MimeType/FileinfoMimeTypeGuesser.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\File\MimeType;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
|
||||
/**
|
||||
* Guesses the mime type using the PECL extension FileInfo.
|
||||
|
|
@ -24,8 +24,6 @@ class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
private $magicFile;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $magicFile A magic file to use with the finfo instance
|
||||
*
|
||||
* @see http://www.php.net/manual/en/function.finfo-open.php
|
||||
|
|
@ -42,7 +40,7 @@ class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return function_exists('finfo_open');
|
||||
return \function_exists('finfo_open');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
3
pfosten/vendor/symfony/http-foundation/File/MimeType/MimeTypeExtensionGuesser.php
vendored
Executable file → Normal file
3
pfosten/vendor/symfony/http-foundation/File/MimeType/MimeTypeExtensionGuesser.php
vendored
Executable file → Normal file
|
|
@ -23,8 +23,6 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface
|
|||
* This list has been updated from upstream on 2013-04-23.
|
||||
*
|
||||
* @see http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultExtensions = array(
|
||||
'application/andrew-inset' => 'ez',
|
||||
|
|
@ -601,6 +599,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface
|
|||
'application/x-xliff+xml' => 'xlf',
|
||||
'application/x-xpinstall' => 'xpi',
|
||||
'application/x-xz' => 'xz',
|
||||
'application/x-zip-compressed' => 'zip',
|
||||
'application/x-zmachine' => 'z1',
|
||||
'application/xaml+xml' => 'xaml',
|
||||
'application/xcap-diff+xml' => 'xdf',
|
||||
|
|
|
|||
25
pfosten/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php
vendored
Executable file → Normal file
25
pfosten/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\File\MimeType;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
|
||||
/**
|
||||
* A singleton mime type guesser.
|
||||
|
|
@ -80,21 +80,14 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
*/
|
||||
private function __construct()
|
||||
{
|
||||
if (FileBinaryMimeTypeGuesser::isSupported()) {
|
||||
$this->register(new FileBinaryMimeTypeGuesser());
|
||||
}
|
||||
|
||||
if (FileinfoMimeTypeGuesser::isSupported()) {
|
||||
$this->register(new FileinfoMimeTypeGuesser());
|
||||
}
|
||||
$this->register(new FileBinaryMimeTypeGuesser());
|
||||
$this->register(new FileinfoMimeTypeGuesser());
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new mime type guesser.
|
||||
*
|
||||
* When guessing, this guesser is preferred over previously registered ones.
|
||||
*
|
||||
* @param MimeTypeGuesserInterface $guesser
|
||||
*/
|
||||
public function register(MimeTypeGuesserInterface $guesser)
|
||||
{
|
||||
|
|
@ -127,18 +120,14 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
throw new AccessDeniedException($path);
|
||||
}
|
||||
|
||||
if (!$this->guessers) {
|
||||
$msg = 'Unable to guess the mime type as no guessers are available';
|
||||
if (!FileinfoMimeTypeGuesser::isSupported()) {
|
||||
$msg .= ' (Did you enable the php_fileinfo extension?)';
|
||||
}
|
||||
throw new \LogicException($msg);
|
||||
}
|
||||
|
||||
foreach ($this->guessers as $guesser) {
|
||||
if (null !== $mimeType = $guesser->guess($path)) {
|
||||
return $mimeType;
|
||||
}
|
||||
}
|
||||
|
||||
if (2 === \count($this->guessers) && !FileBinaryMimeTypeGuesser::isSupported() && !FileinfoMimeTypeGuesser::isSupported()) {
|
||||
throw new \LogicException('Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesserInterface.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesserInterface.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\HttpFoundation\File\MimeType;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
|
||||
/**
|
||||
* Guesses the mime type of a file.
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/http-foundation/File/Stream.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/http-foundation/File/Stream.php
vendored
Executable file → Normal file
55
pfosten/vendor/symfony/http-foundation/File/UploadedFile.php
vendored
Executable file → Normal file
55
pfosten/vendor/symfony/http-foundation/File/UploadedFile.php
vendored
Executable file → Normal file
|
|
@ -24,41 +24,10 @@ use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser;
|
|||
*/
|
||||
class UploadedFile extends File
|
||||
{
|
||||
/**
|
||||
* Whether the test mode is activated.
|
||||
*
|
||||
* Local files are used in test mode hence the code should not enforce HTTP uploads.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $test = false;
|
||||
|
||||
/**
|
||||
* The original name of the uploaded file.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $originalName;
|
||||
|
||||
/**
|
||||
* The mime type provided by the uploader.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $mimeType;
|
||||
|
||||
/**
|
||||
* The file size provided by the uploader.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
private $size;
|
||||
|
||||
/**
|
||||
* The UPLOAD_ERR_XXX constant provided by the uploader.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
|
|
@ -76,11 +45,12 @@ class UploadedFile extends File
|
|||
* Calling any other method on an non-valid instance will cause an unpredictable result.
|
||||
*
|
||||
* @param string $path The full temporary path to the file
|
||||
* @param string $originalName The original file name
|
||||
* @param string $originalName The original file name of the uploaded file
|
||||
* @param string|null $mimeType The type of the file as provided by PHP; null defaults to application/octet-stream
|
||||
* @param int|null $size The file size
|
||||
* @param int|null $size The file size provided by the uploader
|
||||
* @param int|null $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants); null defaults to UPLOAD_ERR_OK
|
||||
* @param bool $test Whether the test mode is active
|
||||
* Local files are used in test mode hence the code should not enforce HTTP uploads
|
||||
*
|
||||
* @throws FileException If file_uploads is disabled
|
||||
* @throws FileNotFoundException If the file does not exist
|
||||
|
|
@ -198,7 +168,7 @@ class UploadedFile extends File
|
|||
*/
|
||||
public function isValid()
|
||||
{
|
||||
$isOk = $this->error === UPLOAD_ERR_OK;
|
||||
$isOk = UPLOAD_ERR_OK === $this->error;
|
||||
|
||||
return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname());
|
||||
}
|
||||
|
|
@ -222,9 +192,11 @@ class UploadedFile extends File
|
|||
|
||||
$target = $this->getTargetFile($directory, $name);
|
||||
|
||||
if (!@move_uploaded_file($this->getPathname(), $target)) {
|
||||
$error = error_get_last();
|
||||
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message'])));
|
||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
||||
$moved = move_uploaded_file($this->getPathname(), $target);
|
||||
restore_error_handler();
|
||||
if (!$moved) {
|
||||
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error)));
|
||||
}
|
||||
|
||||
@chmod($target, 0666 & ~umask());
|
||||
|
|
@ -250,17 +222,20 @@ class UploadedFile extends File
|
|||
|
||||
$max = ltrim($iniMax, '+');
|
||||
if (0 === strpos($max, '0x')) {
|
||||
$max = intval($max, 16);
|
||||
$max = \intval($max, 16);
|
||||
} elseif (0 === strpos($max, '0')) {
|
||||
$max = intval($max, 8);
|
||||
$max = \intval($max, 8);
|
||||
} else {
|
||||
$max = (int) $max;
|
||||
}
|
||||
|
||||
switch (substr($iniMax, -1)) {
|
||||
case 't': $max *= 1024;
|
||||
// no break
|
||||
case 'g': $max *= 1024;
|
||||
// no break
|
||||
case 'm': $max *= 1024;
|
||||
// no break
|
||||
case 'k': $max *= 1024;
|
||||
}
|
||||
|
||||
|
|
@ -285,7 +260,7 @@ class UploadedFile extends File
|
|||
);
|
||||
|
||||
$errorCode = $this->error;
|
||||
$maxFilesize = $errorCode === UPLOAD_ERR_INI_SIZE ? self::getMaxFilesize() / 1024 : 0;
|
||||
$maxFilesize = UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0;
|
||||
$message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.';
|
||||
|
||||
return sprintf($message, $this->getClientOriginalName(), $maxFilesize);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue