Upgrade to 3.5
This commit is contained in:
@@ -107,9 +107,10 @@ class FileCache extends Cache
|
||||
*/
|
||||
public function retrieve(string $key)
|
||||
{
|
||||
$file = $this->file($key);
|
||||
$file = $this->file($key);
|
||||
$value = F::read($file);
|
||||
|
||||
return Value::fromJson(F::read($file));
|
||||
return $value ? Value::fromJson($value) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -76,8 +76,12 @@ class Blocks extends Items
|
||||
return [];
|
||||
}
|
||||
|
||||
// no layouts
|
||||
if (array_key_exists('columns', $input[0]) === false) {
|
||||
if (
|
||||
// no columns = no layout
|
||||
array_key_exists('columns', $input[0]) === false ||
|
||||
// checks if this is a block for the builder plugin
|
||||
array_key_exists('_key', $input[0]) === true
|
||||
) {
|
||||
return $input;
|
||||
}
|
||||
|
||||
|
@@ -202,15 +202,23 @@ class FileRules
|
||||
* Validates the extension, MIME type and filename
|
||||
*
|
||||
* @param \Kirby\Cms\File $file
|
||||
* @param string|null $mime If not passed, the MIME type is detected from the file
|
||||
* @param string|null|false $mime If not passed, the MIME type is detected from the file,
|
||||
* if `false`, the MIME type is not validated for performance reasons
|
||||
* @return bool
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If the extension, MIME type or filename is missing or forbidden
|
||||
*/
|
||||
public static function validFile(File $file, ?string $mime = null): bool
|
||||
public static function validFile(File $file, $mime = null): bool
|
||||
{
|
||||
if ($mime === false) {
|
||||
// request to skip the MIME check for performance reasons
|
||||
$validMime = true;
|
||||
} else {
|
||||
$validMime = static::validMime($file, $mime ?? $file->mime());
|
||||
}
|
||||
|
||||
return
|
||||
$validMime &&
|
||||
static::validExtension($file, $file->extension()) &&
|
||||
static::validMime($file, $mime ?? $file->mime()) &&
|
||||
static::validFilename($file, $file->filename());
|
||||
}
|
||||
|
||||
|
@@ -71,7 +71,7 @@ class Media
|
||||
public static function publish(File $file, string $dest): bool
|
||||
{
|
||||
// never publish risky files (e.g. HTML, PHP or Apache config files)
|
||||
FileRules::validFile($file);
|
||||
FileRules::validFile($file, false);
|
||||
|
||||
$src = $file->root();
|
||||
$version = dirname($dest);
|
||||
|
@@ -291,9 +291,9 @@ trait UserActions
|
||||
/**
|
||||
* Reads the user password from disk
|
||||
*
|
||||
* @return string|null
|
||||
* @return string|false
|
||||
*/
|
||||
protected function readPassword(): ?string
|
||||
protected function readPassword()
|
||||
{
|
||||
return F::read($this->root() . '/.htpasswd');
|
||||
}
|
||||
|
@@ -44,11 +44,12 @@ abstract class Handler
|
||||
*/
|
||||
public static function read(string $file): array
|
||||
{
|
||||
if (is_file($file) !== true) {
|
||||
$contents = F::read($file);
|
||||
if ($contents === false) {
|
||||
throw new Exception('The file "' . $file . '" does not exist');
|
||||
}
|
||||
|
||||
return static::decode(F::read($file));
|
||||
return static::decode($contents);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -547,14 +547,19 @@ class F
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the content of a file
|
||||
* Reads the content of a file or requests the
|
||||
* contents of a remote HTTP or HTTPS URL
|
||||
*
|
||||
* @param string $file The path for the file
|
||||
* @param string $file The path for the file or an absolute URL
|
||||
* @return string|false
|
||||
*/
|
||||
public static function read(string $file)
|
||||
{
|
||||
if (is_file($file) !== true) {
|
||||
if (
|
||||
is_file($file) !== true &&
|
||||
Str::startsWith($file, 'https://') !== true &&
|
||||
Str::startsWith($file, 'http://') !== true
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -232,7 +232,7 @@ class File
|
||||
/**
|
||||
* Reads the file content and returns it.
|
||||
*
|
||||
* @return string
|
||||
* @return string|false
|
||||
*/
|
||||
public function read()
|
||||
{
|
||||
|
Reference in New Issue
Block a user