Ensure files are readable before reading in JsonFile, fixes #11077
parent
205ba37825
commit
80907cd75d
|
@ -93,6 +93,9 @@ class JsonFile
|
||||||
if ($this->httpDownloader) {
|
if ($this->httpDownloader) {
|
||||||
$json = $this->httpDownloader->get($this->path)->getBody();
|
$json = $this->httpDownloader->get($this->path)->getBody();
|
||||||
} else {
|
} else {
|
||||||
|
if (!is_readable($this->path)) {
|
||||||
|
throw new \RuntimeException('The file "'.$this->path.'" is not readable.');
|
||||||
|
}
|
||||||
if ($this->io && $this->io->isDebug()) {
|
if ($this->io && $this->io->isDebug()) {
|
||||||
$realpathInfo = '';
|
$realpathInfo = '';
|
||||||
$realpath = realpath($this->path);
|
$realpath = realpath($this->path);
|
||||||
|
@ -190,6 +193,9 @@ class JsonFile
|
||||||
*/
|
*/
|
||||||
public function validateSchema(int $schema = self::STRICT_SCHEMA, ?string $schemaFile = null): bool
|
public function validateSchema(int $schema = self::STRICT_SCHEMA, ?string $schemaFile = null): bool
|
||||||
{
|
{
|
||||||
|
if (!is_readable($this->path)) {
|
||||||
|
throw new \RuntimeException('The file "'.$this->path.'" is not readable.');
|
||||||
|
}
|
||||||
$content = file_get_contents($this->path);
|
$content = file_get_contents($this->path);
|
||||||
$data = json_decode($content);
|
$data = json_decode($content);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue