* @return string
*/
private function serializeGroupRestrictions(array $groups): string {
- return \json_encode($groups);
+ return \json_encode($groups, JSON_THROW_ON_ERROR);
}
/**
// Return early if an error occurs during parsing.
$this->logger->error($e->getMessage());
$response->setStatus(Http::STATUS_BAD_REQUEST);
- $response->setBody(json_encode($writtenFiles));
+ $response->setBody(json_encode($writtenFiles, JSON_THROW_ON_ERROR));
return false;
}
}
$response->setStatus(Http::STATUS_OK);
- $response->setBody(json_encode($writtenFiles));
+ $response->setBody(json_encode($writtenFiles, JSON_THROW_ON_ERROR));
return false;
}
}
// group restrictions contains something, but not parsable, deny access and log warning
- $json = json_decode($row['group_restrictions']);
+ $json = json_decode($row['group_restrictions'], null, 512, JSON_THROW_ON_ERROR);
if (!\is_array($json)) {
$this->logger->info('group_restrictions field could not be parsed for ' . $this->dbTableName . '::' . $row['id'] . ', denying access to resource');
return false;
*/
private function createComment($objectType, $objectId, $data, $contentType = 'application/json') {
if (explode(';', $contentType)[0] === 'application/json') {
- $data = json_decode($data, true);
+ $data = json_decode($data, true, 512, JSON_THROW_ON_ERROR);
} else {
throw new UnsupportedMediaType();
}
$user->getUID()
);
$ocmPermissions = $this->ncPermissions2ocmPermissions($ncPermissions);
- return json_encode($ocmPermissions);
+ return json_encode($ocmPermissions, JSON_THROW_ON_ERROR);
});
$propFind->handle(self::SHARE_ATTRIBUTES_PROPERTYNAME, function () use ($node, $httpRequest) {
- return json_encode($node->getShareAttributes());
+ return json_encode($node->getShareAttributes(), JSON_THROW_ON_ERROR);
});
$propFind->handle(self::GETETAG_PROPERTYNAME, function () use ($node): string {
});
$propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {
- return json_encode($this->previewManager->isAvailable($node->getFileInfo()));
+ return json_encode($this->previewManager->isAvailable($node->getFileInfo()), JSON_THROW_ON_ERROR);
});
$propFind->handle(self::SIZE_PROPERTYNAME, function () use ($node): ?int {
return $node->getSize();
if ($this->config->getSystemValueBool('enable_file_metadata', true)) {
$propFind->handle(self::FILE_METADATA_SIZE, function () use ($node) {
if (!str_starts_with($node->getFileInfo()->getMimetype(), 'image')) {
- return json_encode((object)[]);
+ return json_encode((object)[], JSON_THROW_ON_ERROR);
}
if ($node->hasMetadata('size')) {
\OC::$server->get(LoggerInterface::class)->debug('Inefficient fetching of metadata');
}
- return json_encode((object)$sizeMetadata->getMetadata());
+ return json_encode((object)$sizeMetadata->getMetadata(), JSON_THROW_ON_ERROR);
});
}
}
*/
private function createTag($data, $contentType = 'application/json') {
if (explode(';', $contentType)[0] === 'application/json') {
- $data = json_decode($data, true);
+ $data = json_decode($data, true, 512, JSON_THROW_ON_ERROR);
} else {
throw new UnsupportedMediaType();
}
$exportDestination->addFileContents($exportPath, $this->serializeCards($vCards));
$metadata = array_filter(['displayName' => $displayName, 'description' => $description]);
- $exportDestination->addFileContents($metadataExportPath, json_encode($metadata));
+ $exportDestination->addFileContents($metadataExportPath, json_encode($metadata, JSON_THROW_ON_ERROR));
}
} catch (Throwable $e) {
throw new CalendarMigratorException('Could not export address book', 0, $e);