1
0
Fork 0

Ensure files are readable before reading in JsonFile, fixes #11077

pull/11120/head
Jordi Boggiano 2022-10-13 14:07:06 +02:00
parent 205ba37825
commit 80907cd75d
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 6 additions and 0 deletions

View File

@ -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);