Skip to content

Firefly III: a personal finances manager

Include safe methods and require the correct package.

James Cole9a02739251ca
diff --git a/app/Console/Commands/Export/ExportsData.php b/app/Console/Commands/Export/ExportsData.php
index a4cc991d89..9205749126 100644
--- a/app/Console/Commands/Export/ExportsData.php
+++ b/app/Console/Commands/Export/ExportsData.php
@@ -283,7 +283,7 @@ class ExportsData extends Command
$this->friendlyWarning(sprintf('File "%s" exists already but will be replaced.', $file));
}
// continue to write to file.
- file_put_contents($file, $content);
+ \Safe\file_put_contents($file, $content);
$this->friendlyPositive(sprintf('Wrote %s-export to file "%s".', $key, $file));
}
}
diff --git a/app/Console/Commands/System/ForcesDecimalSize.php b/app/Console/Commands/System/ForcesDecimalSize.php
index 66340b4c6c..eaec52cdfb 100644
--- a/app/Console/Commands/System/ForcesDecimalSize.php
+++ b/app/Console/Commands/System/ForcesDecimalSize.php
@@ -130,7 +130,7 @@ class ForcesDecimalSize extends Command
// if sqlite, add function?
if ('sqlite' === (string) config('database.default')) {
DB::connection()->getPdo()->sqliteCreateFunction('REGEXP', static function ($pattern, $value) {
- mb_regex_encoding('UTF-8');
+ \Safe\mb_regex_encoding('UTF-8');
$pattern = trim($pattern, '"');
return (false !== mb_ereg($pattern, (string) $value)) ? 1 : 0;
@@ -234,7 +234,7 @@ class ForcesDecimalSize extends Command
/** @var Builder $query */
$query = Account::leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('account_meta.name', 'currency_id')
- ->where('account_meta.data', json_encode((string) $currency->id))
+ ->where('account_meta.data', \Safe\json_encode((string) $currency->id))
;
$query->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
foreach ($fields as $field) {
@@ -338,7 +338,7 @@ class ForcesDecimalSize extends Command
->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('account_meta.name', 'currency_id')
- ->where('account_meta.data', json_encode((string) $currency->id))
+ ->where('account_meta.data', \Safe\json_encode((string) $currency->id))
->where(static function (Builder $q) use ($fields, $currency, $cast, $operator, $regularExpression): void {
foreach ($fields as $field) {
$q->orWhere(
@@ -394,7 +394,7 @@ class ForcesDecimalSize extends Command
->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('account_meta.name', 'currency_id')
- ->where('account_meta.data', json_encode((string) $currency->id))
+ ->where('account_meta.data', \Safe\json_encode((string) $currency->id))
->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
foreach ($fields as $field) {
$q->orWhere(
@@ -448,7 +448,7 @@ class ForcesDecimalSize extends Command
$query = PiggyBank::leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('account_meta.name', 'currency_id')
- ->where('account_meta.data', json_encode((string) $currency->id))
+ ->where('account_meta.data', \Safe\json_encode((string) $currency->id))
->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
foreach ($fields as $field) {
$q->orWhere(
diff --git a/app/Console/Commands/System/ScansAttachments.php b/app/Console/Commands/System/ScansAttachments.php
index b5fad33afa..001f2ec80c 100644
--- a/app/Console/Commands/System/ScansAttachments.php
+++ b/app/Console/Commands/System/ScansAttachments.php
@@ -63,15 +63,15 @@ class ScansAttachments extends Command
app('log')->error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
$decryptedContent = $encryptedContent;
}
- $tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');
+ $tempFileName = \Safe\tempnam(sys_get_temp_dir(), 'FireflyIII');
if (false === $tempFileName) {
app('log')->error(sprintf('Could not create temporary file for attachment #%d', $attachment->id));
exit(1);
}
- file_put_contents($tempFileName, $decryptedContent);
- $attachment->md5 = (string) md5_file($tempFileName);
- $attachment->mime = (string) mime_content_type($tempFileName);
+ \Safe\file_put_contents($tempFileName, $decryptedContent);
+ $attachment->md5 = (string) \Safe\md5_file($tempFileName);
+ $attachment->mime = (string) \Safe\mime_content_type($tempFileName);
$attachment->save();
$this->friendlyInfo(sprintf('Fixed attachment #%d', $attachment->id));
}
diff --git a/app/Console/Commands/System/VerifySecurityAlerts.php b/app/Console/Commands/System/VerifySecurityAlerts.php
index 894c73daa2..0cad167ccb 100644
--- a/app/Console/Commands/System/VerifySecurityAlerts.php
+++ b/app/Console/Commands/System/VerifySecurityAlerts.php
@@ -57,7 +57,7 @@ class VerifySecurityAlerts extends Command
return 0;
}
$content = $disk->get('alerts.json');
- $json = json_decode($content, true, 10);
+ $json = \Safe\json_decode($content, true, 10);
/** @var array $array */
foreach ($json as $array) {
diff --git a/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php b/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php
index 89a961925c..9bc4477888 100644
--- a/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php
+++ b/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php
@@ -167,7 +167,7 @@ class RemovesDatabaseDecryption extends Command
{
// try to json_decrypt the value.
try {
- $newValue = json_decode($value, true, 512, JSON_THROW_ON_ERROR) ?? $value;
+ $newValue = \Safe\json_decode($value, true, 512, JSON_THROW_ON_ERROR) ?? $value;
} catch (\JsonException $e) {
$message = sprintf('Could not JSON decode preference row #%d: %s. This does not have to be a problem.', $id, $e->getMessage());
$this->friendlyError($message);
diff --git a/app/Console/Commands/Upgrade/UpgradesDatabase.php b/app/Console/Commands/Upgrade/UpgradesDatabase.php
index 8a02417a36..b6e5764dd4 100644
--- a/app/Console/Commands/Upgrade/UpgradesDatabase.php
+++ b/app/Console/Commands/Upgrade/UpgradesDatabase.php
@@ -28,7 +28,7 @@ use Illuminate\Support\Facades\Log;
use Safe\Exceptions\InfoException;
try {
- set_time_limit(0);
+ \Safe\set_time_limit(0);
} catch (InfoException) {
Log::warning('set_time_limit returned false. This could be an issue, unless you also run XDebug.');
}
diff --git a/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php b/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php
index d20f763945..39a715ced9 100644
--- a/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php
+++ b/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php
@@ -100,7 +100,7 @@ class UpgradesRecurrenceMetaData extends Command
if ('tags' === $meta->name) {
$array = explode(',', $meta->value);
- $value = json_encode($array, JSON_THROW_ON_ERROR);
+ $value = \Safe\json_encode($array, JSON_THROW_ON_ERROR);
}
RecurrenceTransactionMeta::create(
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index b3099b54e9..9368d57cc0 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -239,7 +239,7 @@ class Handler extends ExceptionHandler
'json' => request()->acceptsJson(),
'method' => request()->method(),
'headers' => $headers,
- 'post' => 'POST' === request()->method() ? json_encode(request()->all()) : '',
+ 'post' => 'POST' === request()->method() ? \Safe\json_encode(request()->all()) : '',
];
// create job that will mail.
@@ -286,8 +286,8 @@ class Handler extends ExceptionHandler
}
$safe = route('index');
$previous = $exception->redirectTo;
- $previousHost = parse_url($previous, PHP_URL_HOST);
- $safeHost = parse_url($safe, PHP_URL_HOST);
+ $previousHost = \Safe\parse_url($previous, PHP_URL_HOST);
+ $safeHost = \Safe\parse_url($safe, PHP_URL_HOST);
return null !== $previousHost && $previousHost === $safeHost ? $previous : $safe;
}
diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.php
index 5c308c1d08..a6707e8b40 100644
--- a/app/Factory/PiggyBankFactory.php
+++ b/app/Factory/PiggyBankFactory.php
@@ -284,7 +284,7 @@ class PiggyBankFactory
Log::debug(sprintf('Will link account #%d with info: ', $account->id), $toBeLinked[$account->id]);
}
}
- Log::debug(sprintf('Link information: %s', json_encode($toBeLinked)));
+ Log::debug(sprintf('Link information: %s', \Safe\json_encode($toBeLinked)));
if (0 !== count($toBeLinked)) {
$piggyBank->accounts()->sync($toBeLinked);
}
diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php
index 6a1ecbece5..0a75ea3e0c 100644
--- a/app/Factory/TransactionJournalFactory.php
+++ b/app/Factory/TransactionJournalFactory.php
@@ -323,7 +323,7 @@ class TransactionJournalFactory
unset($dataRow['import_hash_v2'], $dataRow['original_source']);
try {
- $json = json_encode($dataRow, JSON_THROW_ON_ERROR);
+ $json = \Safe\json_encode($dataRow, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
Log::error(sprintf('Could not encode dataRow: %s', $e->getMessage()));
$json = microtime();
@@ -352,7 +352,7 @@ class TransactionJournalFactory
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
->whereNotNull('transaction_journals.id')
->where('transaction_journals.user_id', $this->user->id)
- ->where('data', json_encode($hash, JSON_THROW_ON_ERROR))
+ ->where('data', \Safe\json_encode($hash, JSON_THROW_ON_ERROR))
->with(['transactionJournal', 'transactionJournal.transactionGroup'])
->first(['journal_meta.*'])
;
diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php
index 01ed7bb275..3d8583805e 100644
--- a/app/Helpers/Attachments/AttachmentHelper.php
+++ b/app/Helpers/Attachments/AttachmentHelper.php
@@ -118,7 +118,7 @@ class AttachmentHelper implements AttachmentHelperInterface
public function saveAttachmentFromApi(Attachment $attachment, string $content): bool
{
Log::debug(sprintf('Now in %s', __METHOD__));
- $resource = tmpfile();
+ $resource = \Safe\tmpfile();
if (false === $resource) {
Log::error('Cannot create temp-file for file upload.');
@@ -133,17 +133,17 @@ class AttachmentHelper implements AttachmentHelperInterface
$path = stream_get_meta_data($resource)['uri'];
Log::debug(sprintf('Path is %s', $path));
- $result = fwrite($resource, $content);
+ $result = \Safe\fwrite($resource, $content);
if (false === $result) {
Log::error('Could not write temp file.');
return false;
}
Log::debug(sprintf('Wrote %d bytes to temp file.', $result));
- $finfo = finfo_open(FILEINFO_MIME_TYPE);
+ $finfo = \Safe\finfo_open(FILEINFO_MIME_TYPE);
if (false === $finfo) {
Log::error('Could not open finfo.');
- fclose($resource);
+ \Safe\fclose($resource);
return false;
}
@@ -151,7 +151,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$allowedMime = config('firefly.allowedMimes');
if (!in_array($mime, $allowedMime, true)) {
Log::error(sprintf('Mime type %s is not allowed for API file upload.', $mime));
- fclose($resource);
+ \Safe\fclose($resource);
return false;
}
@@ -163,7 +163,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$this->uploadDisk->put($file, $content);
// update attachment.
- $attachment->md5 = (string) md5_file($path);
+ $attachment->md5 = (string) \Safe\md5_file($path);
$attachment->mime = $mime;
$attachment->size = strlen($content);
$attachment->uploaded = true;
@@ -225,7 +225,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$attachment = new Attachment(); // create Attachment object.
$attachment->user()->associate($user);
$attachment->attachable()->associate($model);
- $attachment->md5 = (string) md5_file($file->getRealPath());
+ $attachment->md5 = (string) \Safe\md5_file($file->getRealPath());
$attachment->filename = $file->getClientOriginalName();
$attachment->mime = $file->getMimeType();
$attachment->size = $file->getSize();
@@ -333,7 +333,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/
protected function hasFile(UploadedFile $file, Model $model): bool
{
- $md5 = md5_file($file->getRealPath());
+ $md5 = \Safe\md5_file($file->getRealPath());
$name = $file->getClientOriginalName();
$class = $model::class;
$count = 0;
diff --git a/app/Helpers/Collector/Extensions/MetaCollection.php b/app/Helpers/Collector/Extensions/MetaCollection.php
index 1fab2c652e..37d99ee720 100644
--- a/app/Helpers/Collector/Extensions/MetaCollection.php
+++ b/app/Helpers/Collector/Extensions/MetaCollection.php
@@ -167,7 +167,7 @@ trait MetaCollection
{
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
- $this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($externalId)));
+ $this->query->where('journal_meta.data', '!=', sprintf('%s', \Safe\json_encode($externalId)));
$this->query->whereNull('journal_meta.deleted_at');
return $this;
@@ -190,14 +190,14 @@ trait MetaCollection
{
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_url');
- $this->query->where('journal_meta.data', '!=', json_encode($url));
+ $this->query->where('journal_meta.data', '!=', \Safe\json_encode($url));
return $this;
}
public function excludeInternalReference(string $internalReference): GroupCollectorInterface
{
- $internalReference = (string) json_encode($internalReference);
+ $internalReference = (string) \Safe\json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -211,14 +211,14 @@ trait MetaCollection
{
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'recurrence_id');
- $this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($recurringId)));
+ $this->query->where('journal_meta.data', '!=', sprintf('%s', \Safe\json_encode($recurringId)));
return $this;
}
public function externalIdContains(string $externalId): GroupCollectorInterface
{
- $externalId = (string) json_encode($externalId);
+ $externalId = (string) \Safe\json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -230,7 +230,7 @@ trait MetaCollection
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
{
- $externalId = (string) json_encode($externalId);
+ $externalId = (string) \Safe\json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -242,7 +242,7 @@ trait MetaCollection
public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface
{
- $externalId = (string) json_encode($externalId);
+ $externalId = (string) \Safe\json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -254,7 +254,7 @@ trait MetaCollection
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
{
- $externalId = (string) json_encode($externalId);
+ $externalId = (string) \Safe\json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -266,7 +266,7 @@ trait MetaCollection
public function externalIdEnds(string $externalId): GroupCollectorInterface
{
- $externalId = (string) json_encode($externalId);
+ $externalId = (string) \Safe\json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -278,7 +278,7 @@ trait MetaCollection
public function externalIdStarts(string $externalId): GroupCollectorInterface
{
- $externalId = (string) json_encode($externalId);
+ $externalId = (string) \Safe\json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -291,7 +291,7 @@ trait MetaCollection
public function externalUrlContains(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
- $url = (string) json_encode($url);
+ $url = (string) \Safe\json_encode($url);
$url = str_replace('\\', '\\\\', trim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $url));
@@ -302,7 +302,7 @@ trait MetaCollection
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
- $url = (string) json_encode($url);
+ $url = (string) \Safe\json_encode($url);
$url = str_replace('\\', '\\\\', trim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s%%', $url));
@@ -313,7 +313,7 @@ trait MetaCollection
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
- $url = (string) json_encode($url);
+ $url = (string) \Safe\json_encode($url);
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s', $url));
@@ -324,7 +324,7 @@ trait MetaCollection
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
- $url = (string) json_encode($url);
+ $url = (string) \Safe\json_encode($url);
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
// var_dump($url);
@@ -337,7 +337,7 @@ trait MetaCollection
public function externalUrlEnds(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
- $url = (string) json_encode($url);
+ $url = (string) \Safe\json_encode($url);
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereLike('journal_meta.data', sprintf('%%%s', $url));
@@ -348,7 +348,7 @@ trait MetaCollection
public function externalUrlStarts(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
- $url = (string) json_encode($url);
+ $url = (string) \Safe\json_encode($url);
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
// var_dump($url);
@@ -399,7 +399,7 @@ trait MetaCollection
public function internalReferenceContains(string $internalReference): GroupCollectorInterface
{
- $internalReference = (string) json_encode($internalReference);
+ $internalReference = (string) \Safe\json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
// var_dump($internalReference);
// exit;
@@ -414,7 +414,7 @@ trait MetaCollection
public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface
{
- $internalReference = (string) json_encode($internalReference);
+ $internalReference = (string) \Safe\json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -427,7 +427,7 @@ trait MetaCollection
public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface
{
- $internalReference = (string) json_encode($internalReference);
+ $internalReference = (string) \Safe\json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -440,7 +440,7 @@ trait MetaCollection
public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface
{
- $internalReference = (string) json_encode($internalReference);
+ $internalReference = (string) \Safe\json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -453,7 +453,7 @@ trait MetaCollection
public function internalReferenceEnds(string $internalReference): GroupCollectorInterface
{
- $internalReference = (string) json_encode($internalReference);
+ $internalReference = (string) \Safe\json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -466,7 +466,7 @@ trait MetaCollection
public function internalReferenceStarts(string $internalReference): GroupCollectorInterface
{
- $internalReference = (string) json_encode($internalReference);
+ $internalReference = (string) \Safe\json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -704,7 +704,7 @@ trait MetaCollection
{
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
- $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($externalId)));
+ $this->query->where('journal_meta.data', '=', sprintf('%s', \Safe\json_encode($externalId)));
$this->query->whereNull('journal_meta.deleted_at');
return $this;
@@ -714,7 +714,7 @@ trait MetaCollection
{
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_url');
- $this->query->where('journal_meta.data', '=', json_encode($url));
+ $this->query->where('journal_meta.data', '=', \Safe\json_encode($url));
$this->query->whereNull('journal_meta.deleted_at');
return $this;
@@ -722,12 +722,12 @@ trait MetaCollection
public function setInternalReference(string $internalReference): GroupCollectorInterface
{
- $internalReference = (string) json_encode($internalReference);
+ $internalReference = (string) \Safe\json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
- $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($internalReference)));
+ $this->query->where('journal_meta.data', '=', sprintf('%s', \Safe\json_encode($internalReference)));
$this->query->whereNull('journal_meta.deleted_at');
return $this;
@@ -737,7 +737,7 @@ trait MetaCollection
{
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'recurrence_id');
- $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($recurringId)));
+ $this->query->where('journal_meta.data', '=', sprintf('%s', \Safe\json_encode($recurringId)));
$this->query->whereNull('journal_meta.deleted_at');
return $this;
@@ -747,7 +747,7 @@ trait MetaCollection
{
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'sepa_ct_id');
- $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($sepaCT)));
+ $this->query->where('journal_meta.data', '=', sprintf('%s', \Safe\json_encode($sepaCT)));
$this->query->whereNull('journal_meta.deleted_at');
return $this;
diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php
index 21dcb45a40..4cff722226 100644
--- a/app/Helpers/Collector/GroupCollector.php
+++ b/app/Helpers/Collector/GroupCollector.php
@@ -593,7 +593,7 @@ class GroupCollector implements GroupCollectorInterface
if (array_key_exists('meta_name', $result) && in_array($result['meta_name'], $dates, true)) {
$name = $result['meta_name'];
if (array_key_exists('meta_data', $result) && '' !== (string) $result['meta_data']) {
- $result[$name] = Carbon::createFromFormat('!Y-m-d', substr((string) json_decode($result['meta_data']), 0, 10));
+ $result[$name] = Carbon::createFromFormat('!Y-m-d', substr((string) \Safe\json_decode($result['meta_data']), 0, 10));
}
}
diff --git a/app/Helpers/Webhook/Sha3SignatureGenerator.php b/app/Helpers/Webhook/Sha3SignatureGenerator.php
index de301e3cd0..e1b77af37d 100644
--- a/app/Helpers/Webhook/Sha3SignatureGenerator.php
+++ b/app/Helpers/Webhook/Sha3SignatureGenerator.php
@@ -46,7 +46,7 @@ class Sha3SignatureGenerator implements SignatureGeneratorInterface
$json = '';
try {
- $json = json_encode($message->message, JSON_THROW_ON_ERROR);
+ $json = \Safe\json_encode($message->message, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
app('log')->error('Could not generate hash.');
app('log')->error(sprintf('JSON value: %s', $json));
diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php
index 10ac06ba9b..e7e0819b0c 100644
--- a/app/Http/Controllers/Auth/ForgotPasswordController.php
+++ b/app/Http/Controllers/Auth/ForgotPasswordController.php
@@ -101,7 +101,7 @@ class ForgotPasswordController extends Controller
*/
private function validateHost(): void
{
- $configuredHost = parse_url((string) config('app.url'), PHP_URL_HOST);
+ $configuredHost = \Safe\parse_url((string) config('app.url'), PHP_URL_HOST);
if (false === $configuredHost || null === $configuredHost) {
throw new FireflyException('Please set a valid and correct Firefly III URL in the APP_URL environment variable.');
}
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index f88d7eb99e..c264db1a2c 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -468,14 +468,14 @@ class AccountController extends Controller
Log::debug('Balances exist at:');
foreach ($range as $key => $value) {
$newRange[] = ['date' => $key, 'info' => $value];
- Log::debug(sprintf('%d - %s (%s)', count($newRange) - 1, $key, json_encode($value)));
+ Log::debug(sprintf('%d - %s (%s)', count($newRange) - 1, $key, \Safe\json_encode($value)));
}
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[0]['date'])->endOfDay();
Log::debug(sprintf('Start of loop, $carbon is %s', $carbon->format('Y-m-d H:i:s')));
while ($end->gte($current)) {
$momentBalance = $previous;
// $theDate = $current->format('Y-m-d');
- Log::debug(sprintf('Now at %s, with momentBalance %s', $current->format('Y-m-d H:i:s'), json_encode($momentBalance)));
+ Log::debug(sprintf('Now at %s, with momentBalance %s', $current->format('Y-m-d H:i:s'), \Safe\json_encode($momentBalance)));
// loop over the array with balances, find one that is earlier or on the same day.
while ($carbon->lte($current) && array_key_exists($expectedIndex, $newRange)) {
@@ -490,7 +490,7 @@ class AccountController extends Controller
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[$expectedIndex]['date'])->endOfDay();
}
}
- Log::debug(sprintf('momentBalance is now %s', json_encode($momentBalance)));
+ Log::debug(sprintf('momentBalance is now %s', \Safe\json_encode($momentBalance)));
$return = $this->updateChartKeys($return, $momentBalance);
$previous = $momentBalance;
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 6510d1e8b7..f7e5922f1a 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -83,15 +83,15 @@ abstract class Controller extends BaseController
if ('true' === request()->get('force_default_layout') && 'v2' === config('view.layout')) {
//config('view.layout','v1');
Config::set('view.layout', 'v1');
- View::getFinder()->setPaths([realpath(base_path('resources/views'))]); // @phpstan-ignore-line
+ View::getFinder()->setPaths([\Safe\realpath(base_path('resources/views'))]); // @phpstan-ignore-line
}
View::share('authGuard', $authGuard);
View::share('logoutUrl', $logoutUrl);
// upload size
- $maxFileSize = Steam::phpBytes((string) ini_get('upload_max_filesize'));
- $maxPostSize = Steam::phpBytes((string) ini_get('post_max_size'));
+ $maxFileSize = Steam::phpBytes((string) \Safe\ini_get('upload_max_filesize'));
+ $maxPostSize = Steam::phpBytes((string) \Safe\ini_get('post_max_size'));
$uploadSize = min($maxFileSize, $maxPostSize);
View::share('uploadSize', $uploadSize);
diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php
index 4799310e4a..ece11b3d14 100644
--- a/app/Http/Controllers/DebugController.php
+++ b/app/Http/Controllers/DebugController.php
@@ -139,7 +139,7 @@ class DebugController extends Controller
if ($handler instanceof RotatingFileHandler) {
$logFile = $handler->getUrl();
if (null !== $logFile && file_exists($logFile)) {
- $logContent = file_get_contents($logFile);
+ $logContent = \Safe\file_get_contents($logFile);
}
}
}
@@ -164,8 +164,8 @@ class DebugController extends Controller
private function getSystemInformation(): array
{
- $maxFileSize = Steam::phpBytes((string) ini_get('upload_max_filesize'));
- $maxPostSize = Steam::phpBytes((string) ini_get('post_max_size'));
+ $maxFileSize = Steam::phpBytes((string) \Safe\ini_get('upload_max_filesize'));
+ $maxPostSize = Steam::phpBytes((string) \Safe\ini_get('post_max_size'));
$drivers = DB::availableDrivers();
$currentDriver = DB::getDriverName();
@@ -177,8 +177,8 @@ class DebugController extends Controller
'interface' => \PHP_SAPI,
'bits' => \PHP_INT_SIZE * 8,
'bcscale' => bcscale(),
- 'display_errors' => ini_get('display_errors'),
- 'error_reporting' => $this->errorReporting((int) ini_get('error_reporting')),
+ 'display_errors' => \Safe\ini_get('display_errors'),
+ 'error_reporting' => $this->errorReporting((int) \Safe\ini_get('error_reporting')),
'upload_size' => min($maxFileSize, $maxPostSize),
'all_drivers' => $drivers,
'current_driver' => $currentDriver,
@@ -197,7 +197,7 @@ class DebugController extends Controller
try {
if (file_exists('/var/www/counter-main.txt')) {
- $return['build'] = trim((string) file_get_contents('/var/www/counter-main.txt'));
+ $return['build'] = trim((string) \Safe\file_get_contents('/var/www/counter-main.txt'));
app('log')->debug(sprintf('build is now "%s"', $return['build']));
}
} catch (\Exception $e) {
@@ -207,7 +207,7 @@ class DebugController extends Controller
try {
if (file_exists('/var/www/build-date-main.txt')) {
- $return['build_date'] = trim((string) file_get_contents('/var/www/build-date-main.txt'));
+ $return['build_date'] = trim((string) \Safe\file_get_contents('/var/www/build-date-main.txt'));
}
} catch (\Exception $e) {
app('log')->debug('Could not check build date, but thats ok.');
diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php
index bf8b12af22..eb548bb9e2 100644
--- a/app/Http/Controllers/PreferencesController.php
+++ b/app/Http/Controllers/PreferencesController.php
@@ -149,7 +149,7 @@ class PreferencesController extends Controller
// list of locales also has "equal" which makes it equal to whatever the language is.
try {
- $locales = json_decode((string) file_get_contents(resource_path(sprintf('locales/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR);
+ $locales = \Safe\json_decode((string) \Safe\file_get_contents(resource_path(sprintf('locales/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
app('log')->error($e->getMessage());
$locales = [];
@@ -271,7 +271,7 @@ class PreferencesController extends Controller
// custom fiscal year
$customFiscalYear = 1 === (int) $request->get('customFiscalYear');
- $string = strtotime((string) $request->get('fiscalYearStart'));
+ $string = \Safe\strtotime((string) $request->get('fiscalYearStart'));
if (false !== $string) {
$fiscalYearStart = date('m-d', $string);
Preferences::set('customFiscalYear', $customFiscalYear);
diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.php
index df765dc6fb..6a851d43a1 100644
--- a/app/Http/Controllers/System/InstallController.php
+++ b/app/Http/Controllers/System/InstallController.php
@@ -169,7 +169,7 @@ class InstallController extends Controller
return;
}
- file_put_contents($publicKey, (string) $key->getPublicKey());
- file_put_contents($privateKey, $key->toString('PKCS1'));
+ \Safe\file_put_contents($publicKey, (string) $key->getPublicKey());
+ \Safe\file_put_contents($privateKey, $key->toString('PKCS1'));
}
}
diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.php
index fad87c640a..d306b18c78 100644
--- a/app/Http/Controllers/Transaction/CreateController.php
+++ b/app/Http/Controllers/Transaction/CreateController.php
@@ -116,7 +116,7 @@ class CreateController extends Controller
$accountToTypes = config('firefly.account_to_transaction');
$defaultCurrency = $this->defaultCurrency;
$previousUrl = $this->rememberPreviousUrl('transactions.create.url');
- $parts = parse_url($previousUrl);
+ $parts = \Safe\parse_url($previousUrl);
$search = sprintf('?%s', $parts['query'] ?? '');
$previousUrl = str_replace($search, '', $previousUrl);
if (!is_array($optionalFields)) {
diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.php
index c638deb7c8..1bf0ef9c9f 100644
--- a/app/Http/Controllers/Transaction/EditController.php
+++ b/app/Http/Controllers/Transaction/EditController.php
@@ -85,7 +85,7 @@ class EditController extends Controller
$defaultCurrency = $this->defaultCurrency;
$cash = $repository->getCashAccount();
$previousUrl = $this->rememberPreviousUrl('transactions.edit.url');
- $parts = parse_url($previousUrl);
+ $parts = \Safe\parse_url($previousUrl);
$search = sprintf('?%s', $parts['query'] ?? '');
$previousUrl = str_replace($search, '', $previousUrl);
diff --git a/app/Http/Middleware/AcceptHeaders.php b/app/Http/Middleware/AcceptHeaders.php
index 54c9d1f643..cb3745b904 100644
--- a/app/Http/Middleware/AcceptHeaders.php
+++ b/app/Http/Middleware/AcceptHeaders.php
@@ -71,7 +71,7 @@ class AcceptHeaders
// throw bad request if trace id is not a UUID
$uuid = $request->header('X-Trace-Id');
- if (is_string($uuid) && '' !== trim($uuid) && (1 !== preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)))) {
+ if (is_string($uuid) && '' !== trim($uuid) && (1 !== \Safe\preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)))) {
throw new BadRequestHttpException('Bad X-Trace-Id header.');
}
diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.php
index 44e78bcbdf..a961936c3e 100644
--- a/app/Http/Requests/ReportFormRequest.php
+++ b/app/Http/Requests/ReportFormRequest.php
@@ -143,7 +143,7 @@ class ReportFormRequest extends FormRequest
// validate as date
// if regex for YYYY-MM-DD:
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/';
- $result = preg_match($pattern, $string);
+ $result = \Safe\preg_match($pattern, $string);
if (false !== $result && 0 !== $result) {
try {
$date = new Carbon($parts[1]);
@@ -181,7 +181,7 @@ class ReportFormRequest extends FormRequest
// validate as date
// if regex for YYYY-MM-DD:
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/';
- $result = preg_match($pattern, $string);
+ $result = \Safe\preg_match($pattern, $string);
if (false !== $result && 0 !== $result) {
try {
$date = new Carbon($parts[0]);
diff --git a/app/Jobs/DownloadExchangeRates.php b/app/Jobs/DownloadExchangeRates.php
index 5ba8d7f998..bc17d08316 100644
--- a/app/Jobs/DownloadExchangeRates.php
+++ b/app/Jobs/DownloadExchangeRates.php
@@ -113,7 +113,7 @@ class DownloadExchangeRates implements ShouldQueue
return;
}
$body = (string) $res->getBody();
- $json = json_decode($body, true);
+ $json = \Safe\json_decode($body, true);
if (false === $json || null === $json) {
app('log')->warning(sprintf('Trying to grab "%s" resulted in bad JSON.', $url));
diff --git a/app/Jobs/MailError.php b/app/Jobs/MailError.php
index 0b824a15c7..7b906b93a6 100644
--- a/app/Jobs/MailError.php
+++ b/app/Jobs/MailError.php
@@ -46,7 +46,7 @@ class MailError extends Job implements ShouldQueue
$debug = $this->exception;
unset($debug['stackTrace'], $debug['headers']);
- app('log')->error(sprintf('Exception is: %s', json_encode($debug)));
+ app('log')->error(sprintf('Exception is: %s', \Safe\json_encode($debug)));
}
/**
@@ -117,11 +117,11 @@ class MailError extends Job implements ShouldQueue
if (!file_exists($file)) {
Log::debug(sprintf('Wrote new file in "%s"', $file));
- file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));
+ \Safe\file_put_contents($file, \Safe\json_encode($limits, JSON_PRETTY_PRINT));
}
if (file_exists($file)) {
Log::debug(sprintf('Read file in "%s"', $file));
- $limits = json_decode((string) file_get_contents($file), true);
+ $limits = \Safe\json_decode((string) \Safe\file_get_contents($file), true);
}
// limit reached?
foreach ($types as $type => $info) {
@@ -149,7 +149,7 @@ class MailError extends Job implements ShouldQueue
}
++$limits[$type]['sent'];
}
- file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));
+ \Safe\file_put_contents($file, \Safe\json_encode($limits, JSON_PRETTY_PRINT));
Log::debug('No limits reached, return FALSE.');
return false;
diff --git a/app/Mail/InvitationMail.php b/app/Mail/InvitationMail.php
index 507e2d4ceb..a41e6dbc6d 100644
--- a/app/Mail/InvitationMail.php
+++ b/app/Mail/InvitationMail.php
@@ -43,7 +43,7 @@ class InvitationMail extends Mailable
*/
public function __construct(public string $invitee, public string $admin, public string $url)
{
- $this->host = (string) parse_url($this->url, PHP_URL_HOST);
+ $this->host = (string) \Safe\parse_url($this->url, PHP_URL_HOST);
}
/**
diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php
index fa3b58a5b6..baefb2f9b7 100644
--- a/app/Models/AccountMeta.php
+++ b/app/Models/AccountMeta.php
@@ -47,11 +47,11 @@ class AccountMeta extends Model
public function getDataAttribute(mixed $value): string
{
- return (string) json_decode($value, true);
+ return (string) \Safe\json_decode($value, true);
}
public function setDataAttribute(mixed $value): void
{
- $this->attributes['data'] = json_encode($value);
+ $this->attributes['data'] = \Safe\json_encode($value);
}
}
diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php
index a6a137e975..93abb2cfc1 100644
--- a/app/Models/Configuration.php
+++ b/app/Models/Configuration.php
@@ -50,7 +50,7 @@ class Configuration extends Model
*/
public function getDataAttribute($value)
{
- return json_decode($value);
+ return \Safe\json_decode($value);
}
/**
@@ -58,6 +58,6 @@ class Configuration extends Model
*/
public function setDataAttribute($value): void
{
- $this->attributes['data'] = json_encode($value);
+ $this->attributes['data'] = \Safe\json_encode($value);
}
}
diff --git a/app/Models/TransactionJournalMeta.php b/app/Models/TransactionJournalMeta.php
index 09ac979206..00e2aae961 100644
--- a/app/Models/TransactionJournalMeta.php
+++ b/app/Models/TransactionJournalMeta.php
@@ -52,7 +52,7 @@ class TransactionJournalMeta extends Model
*/
public function getDataAttribute($value)
{
- return json_decode($value, false);
+ return \Safe\json_decode($value, false);
}
/**
@@ -60,7 +60,7 @@ class TransactionJournalMeta extends Model
*/
public function setDataAttribute($value): void
{
- $data = json_encode($value);
+ $data = \Safe\json_encode($value);
$this->attributes['data'] = $data;
$this->attributes['hash'] = hash('sha256', (string) $data);
}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 00829e0538..a7d13a7dfe 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -46,7 +46,7 @@ class AppServiceProvider extends ServiceProvider
'Cache-Control' => 'no-store',
];
$uuid = (string) request()->header('X-Trace-Id');
- if ('' !== trim($uuid) && (1 === preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)))) {
+ if ('' !== trim($uuid) && (1 === \Safe\preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)))) {
$headers['X-Trace-Id'] = $uuid;
}
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 5ca811f570..c498f6a5b1 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -108,7 +108,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
->where('accounts.active', true)
->where(
static function (EloquentBuilder $q1) use ($number): void {
- $json = json_encode($number);
+ $json = \Safe\json_encode($number);
$q1->where('account_meta.name', '=', 'account_number');
$q1->where('account_meta.data', '=', $json);
}
diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php
index 9228a88295..9676766b6c 100644
--- a/app/Repositories/Currency/CurrencyRepository.php
+++ b/app/Repositories/Currency/CurrencyRepository.php
@@ -81,7 +81,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
}
// is being used in accounts:
- $meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((string) $currency->id))->count();
+ $meta = AccountMeta::where('name', 'currency_id')->where('data', \Safe\json_encode((string) $currency->id))->count();
if ($meta > 0) {
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
@@ -89,7 +89,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
}
// second search using integer check.
- $meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((int) $currency->id))->count();
+ $meta = AccountMeta::where('name', 'currency_id')->where('data', \Safe\json_encode((int) $currency->id))->count();
if ($meta > 0) {
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
@@ -117,7 +117,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
// is being used in accounts (as integer)
$meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
->whereNull('accounts.deleted_at')
- ->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode($currency->id))->count()
+ ->where('account_meta.name', 'currency_id')->where('account_meta.data', \Safe\json_encode($currency->id))->count()
;
if ($meta > 0) {
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
diff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.php
index bbbac73933..689e1ace72 100644
--- a/app/Repositories/Recurring/RecurringRepository.php
+++ b/app/Repositories/Recurring/RecurringRepository.php
@@ -68,16 +68,16 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
$set
= TransactionJournalMeta::where(static function (Builder $q1) use ($recurrence): void {
$q1->where('name', 'recurrence_id');
- $q1->where('data', json_encode((string) $recurrence->id));
+ $q1->where('data', \Safe\json_encode((string) $recurrence->id));
})->get(['journal_meta.transaction_journal_id']);
// there are X journals made for this recurrence. Any of them meant for today?
foreach ($set as $journalMeta) {
$count = TransactionJournalMeta::where(static function (Builder $q2) use ($date): void {
$string = (string) $date;
- app('log')->debug(sprintf('Search for date: %s', json_encode($string)));
+ app('log')->debug(sprintf('Search for date: %s', \Safe\json_encode($string)));
$q2->where('name', 'recurrence_date');
- $q2->where('data', json_encode($string));
+ $q2->where('data', \Safe\json_encode($string));
})
->where('transaction_journal_id', $journalMeta->transaction_journal_id)
->count()
@@ -232,7 +232,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
return TransactionJournalMeta::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
->where('transaction_journals.user_id', $this->user->id)
->where('journal_meta.name', '=', 'recurrence_id')
- ->where('journal_meta.data', '=', json_encode((string) $recurrence->id))
+ ->where('journal_meta.data', '=', \Safe\json_encode((string) $recurrence->id))
->get(['journal_meta.transaction_journal_id'])->pluck('transaction_journal_id')->toArray()
;
}
@@ -272,7 +272,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
/** @var RecurrenceMeta $meta */
foreach ($transaction->recurrenceTransactionMeta as $meta) {
if ('tags' === $meta->name && '' !== $meta->value) {
- $tags = json_decode($meta->value, true, 512, JSON_THROW_ON_ERROR);
+ $tags = \Safe\json_decode($meta->value, true, 512, JSON_THROW_ON_ERROR);
}
}
@@ -285,7 +285,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
->whereNull('transaction_journals.deleted_at')
->where('transaction_journals.user_id', $this->user->id)
->where('name', 'recurrence_id')
- ->where('data', json_encode((string) $recurrence->id))
+ ->where('data', \Safe\json_encode((string) $recurrence->id))
->get()->pluck('transaction_journal_id')->toArray()
;
$search = [];
@@ -311,7 +311,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
->whereNull('transaction_journals.deleted_at')
->where('transaction_journals.user_id', $this->user->id)
->where('name', 'recurrence_id')
- ->where('data', json_encode((string) $recurrence->id))
+ ->where('data', \Safe\json_encode((string) $recurrence->id))
->get()->pluck('transaction_journal_id')->toArray()
;
$search = [];
diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.php
index 0a76f9bda2..c9c3063685 100644
--- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php
+++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php
@@ -304,7 +304,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
$return = [];
foreach ($query as $row) {
- $return[$row->name] = new Carbon(json_decode($row->data, true, 512, JSON_THROW_ON_ERROR));
+ $return[$row->name] = new Carbon(\Safe\json_decode($row->data, true, 512, JSON_THROW_ON_ERROR));
}
return new NullArrayObject($return);
@@ -324,7 +324,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
$return = [];
foreach ($query as $row) {
- $return[$row->name] = json_decode($row->data);
+ $return[$row->name] = \Safe\json_decode($row->data);
}
return new NullArrayObject($return);
diff --git a/app/Repositories/UserGroups/Account/AccountRepository.php b/app/Repositories/UserGroups/Account/AccountRepository.php
index c57870fe2c..f7aae4dfce 100644
--- a/app/Repositories/UserGroups/Account/AccountRepository.php
+++ b/app/Repositories/UserGroups/Account/AccountRepository.php
@@ -66,7 +66,7 @@ class AccountRepository implements AccountRepositoryInterface
->where('accounts.active', true)
->where(
static function (EloquentBuilder $q1) use ($number): void {
- $json = json_encode($number);
+ $json = \Safe\json_encode($number);
$q1->where('account_meta.name', '=', 'account_number');
$q1->where('account_meta.data', '=', $json);
}
diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepository.php b/app/Repositories/UserGroups/Currency/CurrencyRepository.php
index da56f7630f..092ef4b50c 100644
--- a/app/Repositories/UserGroups/Currency/CurrencyRepository.php
+++ b/app/Repositories/UserGroups/Currency/CurrencyRepository.php
@@ -81,7 +81,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
}
// is being used in accounts:
- $meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((string) $currency->id))->count();
+ $meta = AccountMeta::where('name', 'currency_id')->where('data', \Safe\json_encode((string) $currency->id))->count();
if ($meta > 0) {
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
@@ -89,7 +89,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
}
// second search using integer check.
- $meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((int) $currency->id))->count();
+ $meta = AccountMeta::where('name', 'currency_id')->where('data', \Safe\json_encode((int) $currency->id))->count();
if ($meta > 0) {
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
@@ -117,7 +117,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// is being used in accounts (as integer)
$meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
->whereNull('accounts.deleted_at')
- ->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode($currency->id))->count()
+ ->where('account_meta.name', 'currency_id')->where('account_meta.data', \Safe\json_encode($currency->id))->count()
;
if ($meta > 0) {
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
diff --git a/app/Rules/IsValidBulkClause.php b/app/Rules/IsValidBulkClause.php
index 57bd227f04..148d5600b1 100644
--- a/app/Rules/IsValidBulkClause.php
+++ b/app/Rules/IsValidBulkClause.php
@@ -63,7 +63,7 @@ class IsValidBulkClause implements ValidationRule
private function basicValidation(string $value): bool
{
try {
- $array = json_decode($value, true, 8, JSON_THROW_ON_ERROR);
+ $array = \Safe\json_decode($value, true, 8, JSON_THROW_ON_ERROR);
} catch (\JsonException) {
$this->error = (string) trans('validation.json');
diff --git a/app/Rules/IsValidPositiveAmount.php b/app/Rules/IsValidPositiveAmount.php
index 89d7ada4a6..5f3cc94f66 100644
--- a/app/Rules/IsValidPositiveAmount.php
+++ b/app/Rules/IsValidPositiveAmount.php
@@ -40,7 +40,7 @@ class IsValidPositiveAmount implements ValidationRule
{
if (is_array($value)) {
$fail('validation.numeric')->translate();
- $message = sprintf('IsValidPositiveAmount: "%s" is not a number.', json_encode($value));
+ $message = sprintf('IsValidPositiveAmount: "%s" is not a number.', \Safe\json_encode($value));
Log::debug($message);
Log::channel('audit')->info($message);
diff --git a/app/Rules/UniqueAccountNumber.php b/app/Rules/UniqueAccountNumber.php
index f51a54caaa..3e02e2c7e9 100644
--- a/app/Rules/UniqueAccountNumber.php
+++ b/app/Rules/UniqueAccountNumber.php
@@ -133,7 +133,7 @@ class UniqueAccountNumber implements ValidationRule
->where('accounts.user_id', auth()->user()->id)
->where('account_types.type', $type)
->where('account_meta.name', '=', 'account_number')
- ->where('account_meta.data', json_encode($accountNumber))
+ ->where('account_meta.data', \Safe\json_encode($accountNumber))
;
if (null !== $this->account) {
diff --git a/app/Services/FireflyIIIOrg/Update/UpdateRequest.php b/app/Services/FireflyIIIOrg/Update/UpdateRequest.php
index 452d3d32a7..29499570bc 100644
--- a/app/Services/FireflyIIIOrg/Update/UpdateRequest.php
+++ b/app/Services/FireflyIIIOrg/Update/UpdateRequest.php
@@ -99,7 +99,7 @@ class UpdateRequest implements UpdateRequestInterface
$body = (string) $res->getBody();
try {
- $json = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
+ $json = \Safe\json_decode($body, true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException) {
Log::error('Body is not valid JSON');
Log::error($body);
diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php
index a85b174a9e..507f65e95e 100644
--- a/app/Services/Internal/Support/JournalServiceTrait.php
+++ b/app/Services/Internal/Support/JournalServiceTrait.php
@@ -260,7 +260,7 @@ trait JournalServiceTrait
if (null === $account) {
// final attempt, create it.
if (AccountTypeEnum::ASSET->value === $preferredType) {
- throw new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', json_encode($data)));
+ throw new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', \Safe\json_encode($data)));
}
// fix name of account if only IBAN is given:
if ('' === (string) $data['name'] && '' !== (string) $data['iban']) {
diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.php
index 9df6075d19..95b5520599 100644
--- a/app/Services/Internal/Support/RecurringTransactionTrait.php
+++ b/app/Services/Internal/Support/RecurringTransactionTrait.php
@@ -307,9 +307,9 @@ trait RecurringTransactionTrait
/** @var null|RecurrenceMeta $entry */
$entry = $transaction->recurrenceTransactionMeta()->where('name', 'tags')->first();
if (null === $entry) {
- $entry = RecurrenceTransactionMeta::create(['rt_id' => $transaction->id, 'name' => 'tags', 'value' => json_encode($tags)]);
+ $entry = RecurrenceTransactionMeta::create(['rt_id' => $transaction->id, 'name' => 'tags', 'value' => \Safe\json_encode($tags)]);
}
- $entry->value = json_encode($tags);
+ $entry->value = \Safe\json_encode($tags);
$entry->save();
}
if (0 === count($tags)) {
diff --git a/app/Services/Webhook/StandardWebhookSender.php b/app/Services/Webhook/StandardWebhookSender.php
index 911fde75d9..264e754bc8 100644
--- a/app/Services/Webhook/StandardWebhookSender.php
+++ b/app/Services/Webhook/StandardWebhookSender.php
@@ -80,7 +80,7 @@ class StandardWebhookSender implements WebhookSenderInterface
app('log')->debug(sprintf('Trying to send webhook message #%d', $this->message->id));
try {
- $json = json_encode($this->message->message, JSON_THROW_ON_ERROR);
+ $json = \Safe\json_encode($this->message->message, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
app('log')->error('Did not send message because of a JSON error.');
app('log')->error($e->getMessage());
diff --git a/app/Support/CacheProperties.php b/app/Support/CacheProperties.php
index 381466b2c9..2a95210a8c 100644
--- a/app/Support/CacheProperties.php
+++ b/app/Support/CacheProperties.php
@@ -79,7 +79,7 @@ class CacheProperties
$content = '';
foreach ($this->properties as $property) {
try {
- $content = sprintf('%s%s', $content, json_encode($property, JSON_THROW_ON_ERROR));
+ $content = sprintf('%s%s', $content, \Safe\json_encode($property, JSON_THROW_ON_ERROR));
} catch (\JsonException) {
// @ignoreException
$content = sprintf('%s%s', $content, hash('sha256', (string) time()));
diff --git a/app/Support/Http/Controllers/CreateStuff.php b/app/Support/Http/Controllers/CreateStuff.php
index 59fe677edd..6fb55a9d22 100644
--- a/app/Support/Http/Controllers/CreateStuff.php
+++ b/app/Support/Http/Controllers/CreateStuff.php
@@ -106,8 +106,8 @@ trait CreateStuff
Log::alert('NO OAuth keys were found. They have been created.');
- file_put_contents($publicKey, (string) $key->getPublicKey());
- file_put_contents($privateKey, $key->toString('PKCS1'));
+ \Safe\file_put_contents($publicKey, (string) $key->getPublicKey());
+ \Safe\file_put_contents($privateKey, $key->toString('PKCS1'));
}
/**
diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.php
index 7307496f2e..7f18f6fe3c 100644
--- a/app/Support/Http/Controllers/RequestInformation.php
+++ b/app/Support/Http/Controllers/RequestInformation.php
@@ -46,7 +46,7 @@ trait RequestInformation
final protected function getDomain(): string // get request info
{
$url = url()->to('/');
- $parts = parse_url($url);
+ $parts = \Safe\parse_url($url);
return $parts['host'] ?? '';
}
diff --git a/app/Support/ParseDateString.php b/app/Support/ParseDateString.php
index 6ddde18a15..4d61dc35d5 100644
--- a/app/Support/ParseDateString.php
+++ b/app/Support/ParseDateString.php
@@ -85,7 +85,7 @@ class ParseDateString
// if regex for YYYY-MM-DD:
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/';
- $result = preg_match($pattern, $date);
+ $result = \Safe\preg_match($pattern, $date);
if (false !== $result && 0 !== $result) {
return $this->parseDefaultDate($date);
}
@@ -182,7 +182,7 @@ class ParseDateString
// verify if correct
$pattern = '/[+-]\d+[wqmdy]/';
- $result = preg_match($pattern, $part);
+ $result = \Safe\preg_match($pattern, $part);
if (0 === $result || false === $result) {
app('log')->error(sprintf('Part "%s" does not match regular expression. Will be skipped.', $part));
@@ -256,7 +256,7 @@ class ParseDateString
protected function isDayRange(string $date): bool
{
$pattern = '/^xxxx-xx-(0[1-9]|[12]\d|3[01])$/';
- $result = preg_match($pattern, $date);
+ $result = \Safe\preg_match($pattern, $date);
if (false !== $result && 0 !== $result) {
app('log')->debug(sprintf('"%s" is a day range.', $date));
@@ -283,7 +283,7 @@ class ParseDateString
{
// if regex for xxxx-MM-xx:
$pattern = '/^xxxx-(0[1-9]|1[012])-xx$/';
- $result = preg_match($pattern, $date);
+ $result = \Safe\preg_match($pattern, $date);
if (false !== $result && 0 !== $result) {
app('log')->debug(sprintf('"%s" is a month range.', $date));
@@ -311,7 +311,7 @@ class ParseDateString
{
// if regex for YYYY-xx-xx:
$pattern = '/^(19|20)\d\d-xx-xx$/';
- $result = preg_match($pattern, $date);
+ $result = \Safe\preg_match($pattern, $date);
if (false !== $result && 0 !== $result) {
app('log')->debug(sprintf('"%s" is a year range.', $date));
@@ -339,7 +339,7 @@ class ParseDateString
{
// if regex for xxxx-MM-DD:
$pattern = '/^xxxx-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/';
- $result = preg_match($pattern, $date);
+ $result = \Safe\preg_match($pattern, $date);
if (false !== $result && 0 !== $result) {
app('log')->debug(sprintf('"%s" is a month/day range.', $date));
@@ -368,7 +368,7 @@ class ParseDateString
{
// if regex for YYYY-xx-DD:
$pattern = '/^(19|20)\d\d-xx-(0[1-9]|[12]\d|3[01])$/';
- $result = preg_match($pattern, $date);
+ $result = \Safe\preg_match($pattern, $date);
if (false !== $result && 0 !== $result) {
app('log')->debug(sprintf('"%s" is a day/year range.', $date));
@@ -397,7 +397,7 @@ class ParseDateString
{
// if regex for YYYY-MM-xx:
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-xx$/';
- $result = preg_match($pattern, $date);
+ $result = \Safe\preg_match($pattern, $date);
if (false !== $result && 0 !== $result) {
app('log')->debug(sprintf('"%s" is a month/year range.', $date));
diff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.php
index 772b6bd36f..0e65fe7343 100644
--- a/app/Support/Request/ConvertsDataTypes.php
+++ b/app/Support/Request/ConvertsDataTypes.php
@@ -125,7 +125,7 @@ trait ConvertsDataTypes
$string = str_replace($this->characters, "\x20", $string);
// clear zalgo text (TODO also in API v2)
- $string = preg_replace('/(\pM{2})\pM+/u', '\1', $string);
+ $string = \Safe\preg_replace('/(\pM{2})\pM+/u', '\1', $string);
return trim((string) $string);
}
diff --git a/app/Support/Search/AccountSearch.php b/app/Support/Search/AccountSearch.php
index ec5ef15e58..a40c407e3f 100644
--- a/app/Support/Search/AccountSearch.php
+++ b/app/Support/Search/AccountSearch.php
@@ -81,7 +81,7 @@ class AccountSearch implements GenericSearchInterface
// meta data:
$searchQuery->orWhere(
static function (Builder $q) use ($originalQuery): void {
- $json = json_encode($originalQuery, JSON_THROW_ON_ERROR);
+ $json = \Safe\json_encode($originalQuery, JSON_THROW_ON_ERROR);
$q->where('account_meta.name', '=', 'account_number');
$q->whereLike('account_meta.data', $json);
}
@@ -108,7 +108,7 @@ class AccountSearch implements GenericSearchInterface
// meta data:
$searchQuery->Where(
static function (Builder $q) use ($originalQuery): void {
- $json = json_encode($originalQuery, JSON_THROW_ON_ERROR);
+ $json = \Safe\json_encode($originalQuery, JSON_THROW_ON_ERROR);
$q->where('account_meta.name', 'account_number');
$q->where('account_meta.data', $json);
}
diff --git a/app/Support/Search/QueryParser/GdbotsQueryParser.php b/app/Support/Search/QueryParser/GdbotsQueryParser.php
index eec1259988..aa802e0df0 100644
--- a/app/Support/Search/QueryParser/GdbotsQueryParser.php
+++ b/app/Support/Search/QueryParser/GdbotsQueryParser.php
@@ -54,7 +54,7 @@ class GdbotsQueryParser implements QueryParserInterface
return new NodeGroup($nodes);
} catch (\LogicException|\TypeError $e) {
- fwrite(STDERR, "Setting up GdbotsQueryParserTest\n");
+ \Safe\fwrite(STDERR, "Setting up GdbotsQueryParserTest\n");
app('log')->error($e->getMessage());
app('log')->error(sprintf('Could not parse search: "%s".', $query));
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index 6001cdbdc0..b6da6a44dd 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -184,8 +184,8 @@ class Steam
];
// clear zalgo text
- $string = preg_replace('/(\pM{2})\pM+/u', '\1', $string);
- $string = preg_replace('/\s+/', '', $string);
+ $string = \Safe\preg_replace('/(\pM{2})\pM+/u', '\1', $string);
+ $string = \Safe\preg_replace('/\s+/', '', $string);
return str_replace($search, '', $string);
}
@@ -566,8 +566,8 @@ class Steam
{
// Log::debug(sprintf('getSafeUrl(%s, %s)', $unknownUrl, $safeUrl));
$returnUrl = $safeUrl;
- $unknownHost = parse_url($unknownUrl, PHP_URL_HOST);
- $safeHost = parse_url($safeUrl, PHP_URL_HOST);
+ $unknownHost = \Safe\parse_url($unknownUrl, PHP_URL_HOST);
+ $safeHost = \Safe\parse_url($safeUrl, PHP_URL_HOST);
if (null !== $unknownHost && $unknownHost === $safeHost) {
$returnUrl = $unknownUrl;
diff --git a/app/Support/System/OAuthKeys.php b/app/Support/System/OAuthKeys.php
index cda0721846..e0c0fa0b7a 100644
--- a/app/Support/System/OAuthKeys.php
+++ b/app/Support/System/OAuthKeys.php
@@ -96,8 +96,8 @@ class OAuthKeys
{
$private = storage_path('oauth-private.key');
$public = storage_path('oauth-public.key');
- app('fireflyconfig')->set(self::PRIVATE_KEY, Crypt::encrypt(file_get_contents($private)));
- app('fireflyconfig')->set(self::PUBLIC_KEY, Crypt::encrypt(file_get_contents($public)));
+ app('fireflyconfig')->set(self::PRIVATE_KEY, Crypt::encrypt(\Safe\file_get_contents($private)));
+ app('fireflyconfig')->set(self::PUBLIC_KEY, Crypt::encrypt(\Safe\file_get_contents($public)));
}
/**
@@ -123,8 +123,8 @@ class OAuthKeys
}
$private = storage_path('oauth-private.key');
$public = storage_path('oauth-public.key');
- file_put_contents($private, $privateContent);
- file_put_contents($public, $publicContent);
+ \Safe\file_put_contents($private, $privateContent);
+ \Safe\file_put_contents($public, $publicContent);
return true;
}
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index 94ec12be36..96b7475dac 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -179,8 +179,8 @@ class General extends AbstractExtension
return new TwigFilter(
'phphost',
static function (string $string): string {
- $proto = (string) parse_url($string, PHP_URL_SCHEME);
- $host = (string) parse_url($string, PHP_URL_HOST);
+ $proto = (string) \Safe\parse_url($string, PHP_URL_SCHEME);
+ $host = (string) \Safe\parse_url($string, PHP_URL_HOST);
return e(sprintf('%s://%s', $proto, $host));
}
diff --git a/app/Support/Twig/TransactionGroupTwig.php b/app/Support/Twig/TransactionGroupTwig.php
index df56cc8365..bc338d4b22 100644
--- a/app/Support/Twig/TransactionGroupTwig.php
+++ b/app/Support/Twig/TransactionGroupTwig.php
@@ -255,7 +255,7 @@ class TransactionGroupTwig extends AbstractExtension
return today(config('app.timezone'));
}
- return new Carbon(json_decode($entry->data, false));
+ return new Carbon(\Safe\json_decode($entry->data, false));
}
);
}
@@ -276,7 +276,7 @@ class TransactionGroupTwig extends AbstractExtension
return '';
}
- return json_decode($entry->data, true);
+ return \Safe\json_decode($entry->data, true);
}
);
}
diff --git a/app/Transformers/RecurrenceTransformer.php b/app/Transformers/RecurrenceTransformer.php
index 251386c627..5abe8b2615 100644
--- a/app/Transformers/RecurrenceTransformer.php
+++ b/app/Transformers/RecurrenceTransformer.php
@@ -264,7 +264,7 @@ class RecurrenceTransformer extends AbstractTransformer
break;
case 'tags':
- $array['tags'] = json_decode($transactionMeta->value);
+ $array['tags'] = \Safe\json_decode($transactionMeta->value);
break;
diff --git a/app/Transformers/WebhookMessageTransformer.php b/app/Transformers/WebhookMessageTransformer.php
index f0fd5c056d..5271582bbb 100644
--- a/app/Transformers/WebhookMessageTransformer.php
+++ b/app/Transformers/WebhookMessageTransformer.php
@@ -39,7 +39,7 @@ class WebhookMessageTransformer extends AbstractTransformer
$json = '{}';
try {
- $json = json_encode($message->message, JSON_THROW_ON_ERROR);
+ $json = \Safe\json_encode($message->message, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
app('log')->error(sprintf('Could not encode webhook message #%d: %s', $message->id, $e->getMessage()));
}
diff --git a/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php b/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php
index 876d4269be..c5651941d4 100644
--- a/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php
+++ b/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php
@@ -34,7 +34,7 @@ trait ValidatesBulkTransactionQuery
$data = $validator->getData();
// assumption is all validation has already taken place and the query key exists.
$query = $data['query'] ?? '[]';
- $json = json_decode($query, true, 8, JSON_THROW_ON_ERROR);
+ $json = \Safe\json_decode($query, true, 8, JSON_THROW_ON_ERROR);
if (
array_key_exists('where', $json)
diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php
index aa9b0d927c..86409ed951 100644
--- a/app/Validation/FireflyValidator.php
+++ b/app/Validation/FireflyValidator.php
@@ -110,7 +110,7 @@ class FireflyValidator extends Validator
return false;
}
$regex = '/^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?\z/i';
- $result = preg_match($regex, $value);
+ $result = \Safe\preg_match($regex, $value);
if (false === $result || 0 === $result) {
return false;
}
@@ -200,7 +200,7 @@ class FireflyValidator extends Validator
$value = strtoupper($value);
// replace characters outside of ASCI range.
- $value = (string) iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $value);
+ $value = (string) \Safe\iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $value);
$search = [' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
$replace = ['', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35'];
@@ -634,7 +634,7 @@ class FireflyValidator extends Validator
->whereNull('accounts.deleted_at')
->where('accounts.user_id', auth()->user()->id)
->where('account_meta.name', 'account_number')
- ->where('account_meta.data', json_encode($value))
+ ->where('account_meta.data', \Safe\json_encode($value))
;
if ($accountId > 0) {
diff --git a/composer.json b/composer.json
index 8a461e9fe3..6bfcb45017 100644
--- a/composer.json
+++ b/composer.json
@@ -107,7 +107,8 @@
"spatie/period": "^2.4",
"symfony/expression-language": "^7.0",
"symfony/http-client": "^7.1",
- "symfony/mailgun-mailer": "^7.1"
+ "symfony/mailgun-mailer": "^7.1",
+ "thecodingmachine/safe": "^3.1"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.9",
diff --git a/composer.lock b/composer.lock
index d42ce90769..44990b10ee 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "be90fbe2c861ffb51547daafa97e4473",
+ "content-hash": "4ac1fa9e94ed4eef76cda81afe72d054",
"packages": [
{
"name": "bacon/bacon-qr-code",
@@ -9292,6 +9292,145 @@
],
"time": "2025-05-02T08:36:00+00:00"
},
+ {
+ "name": "thecodingmachine/safe",
+ "version": "v3.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/thecodingmachine/safe.git",
+ "reference": "234f6fe34a0bead8c5ae1cfc0800539442e6f619"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/thecodingmachine/safe/zipball/234f6fe34a0bead8c5ae1cfc0800539442e6f619",
+ "reference": "234f6fe34a0bead8c5ae1cfc0800539442e6f619",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^8.1"
+ },
+ "require-dev": {
+ "php-parallel-lint/php-parallel-lint": "^1.4",
+ "phpstan/phpstan": "^2",
+ "phpunit/phpunit": "^10",
+ "squizlabs/php_codesniffer": "^3.2"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "lib/special_cases.php",
+ "generated/apache.php",
+ "generated/apcu.php",
+ "generated/array.php",
+ "generated/bzip2.php",
+ "generated/calendar.php",
+ "generated/classobj.php",
+ "generated/com.php",
+ "generated/cubrid.php",
+ "generated/curl.php",
+ "generated/datetime.php",
+ "generated/dir.php",
+ "generated/eio.php",
+ "generated/errorfunc.php",
+ "generated/exec.php",
+ "generated/fileinfo.php",
+ "generated/filesystem.php",
+ "generated/filter.php",
+ "generated/fpm.php",
+ "generated/ftp.php",
+ "generated/funchand.php",
+ "generated/gettext.php",
+ "generated/gmp.php",
+ "generated/gnupg.php",
+ "generated/hash.php",
+ "generated/ibase.php",
+ "generated/ibmDb2.php",
+ "generated/iconv.php",
+ "generated/image.php",
+ "generated/imap.php",
+ "generated/info.php",
+ "generated/inotify.php",
+ "generated/json.php",
+ "generated/ldap.php",
+ "generated/libxml.php",
+ "generated/lzf.php",
+ "generated/mailparse.php",
+ "generated/mbstring.php",
+ "generated/misc.php",
+ "generated/mysql.php",
+ "generated/mysqli.php",
+ "generated/network.php",
+ "generated/oci8.php",
+ "generated/opcache.php",
+ "generated/openssl.php",
+ "generated/outcontrol.php",
+ "generated/pcntl.php",
+ "generated/pcre.php",
+ "generated/pgsql.php",
+ "generated/posix.php",
+ "generated/ps.php",
+ "generated/pspell.php",
+ "generated/readline.php",
+ "generated/rnp.php",
+ "generated/rpminfo.php",
+ "generated/rrd.php",
+ "generated/sem.php",
+ "generated/session.php",
+ "generated/shmop.php",
+ "generated/sockets.php",
+ "generated/sodium.php",
+ "generated/solr.php",
+ "generated/spl.php",
+ "generated/sqlsrv.php",
+ "generated/ssdeep.php",
+ "generated/ssh2.php",
+ "generated/stream.php",
+ "generated/strings.php",
+ "generated/swoole.php",
+ "generated/uodbc.php",
+ "generated/uopz.php",
+ "generated/url.php",
+ "generated/var.php",
+ "generated/xdiff.php",
+ "generated/xml.php",
+ "generated/xmlrpc.php",
+ "generated/yaml.php",
+ "generated/yaz.php",
+ "generated/zip.php",
+ "generated/zlib.php"
+ ],
+ "classmap": [
+ "lib/DateTime.php",
+ "lib/DateTimeImmutable.php",
+ "lib/Exceptions/",
+ "generated/Exceptions/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHP core functions that throw exceptions instead of returning FALSE on error",
+ "support": {
+ "issues": "https://github.com/thecodingmachine/safe/issues",
+ "source": "https://github.com/thecodingmachine/safe/tree/v3.1.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/OskarStark",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/shish",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/staabm",
+ "type": "github"
+ }
+ ],
+ "time": "2025-04-28T07:56:17+00:00"
+ },
{
"name": "tijsverkoyen/css-to-inline-styles",
"version": "v2.3.0",
@@ -12405,145 +12544,6 @@
},
"time": "2025-02-11T12:41:29+00:00"
},
- {
- "name": "thecodingmachine/safe",
- "version": "v3.1.1",
- "source": {
- "type": "git",
- "url": "https://github.com/thecodingmachine/safe.git",
- "reference": "234f6fe34a0bead8c5ae1cfc0800539442e6f619"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/thecodingmachine/safe/zipball/234f6fe34a0bead8c5ae1cfc0800539442e6f619",
- "reference": "234f6fe34a0bead8c5ae1cfc0800539442e6f619",
- "shasum": ""
- },
- "require": {
- "php": "^8.1"
- },
- "require-dev": {
- "php-parallel-lint/php-parallel-lint": "^1.4",
- "phpstan/phpstan": "^2",
- "phpunit/phpunit": "^10",
- "squizlabs/php_codesniffer": "^3.2"
- },
- "type": "library",
- "autoload": {
- "files": [
- "lib/special_cases.php",
- "generated/apache.php",
- "generated/apcu.php",
- "generated/array.php",
- "generated/bzip2.php",
- "generated/calendar.php",
- "generated/classobj.php",
- "generated/com.php",
- "generated/cubrid.php",
- "generated/curl.php",
- "generated/datetime.php",
- "generated/dir.php",
- "generated/eio.php",
- "generated/errorfunc.php",
- "generated/exec.php",
- "generated/fileinfo.php",
- "generated/filesystem.php",
- "generated/filter.php",
- "generated/fpm.php",
- "generated/ftp.php",
- "generated/funchand.php",
- "generated/gettext.php",
- "generated/gmp.php",
- "generated/gnupg.php",
- "generated/hash.php",
- "generated/ibase.php",
- "generated/ibmDb2.php",
- "generated/iconv.php",
- "generated/image.php",
- "generated/imap.php",
- "generated/info.php",
- "generated/inotify.php",
- "generated/json.php",
- "generated/ldap.php",
- "generated/libxml.php",
- "generated/lzf.php",
- "generated/mailparse.php",
- "generated/mbstring.php",
- "generated/misc.php",
- "generated/mysql.php",
- "generated/mysqli.php",
- "generated/network.php",
- "generated/oci8.php",
- "generated/opcache.php",
- "generated/openssl.php",
- "generated/outcontrol.php",
- "generated/pcntl.php",
- "generated/pcre.php",
- "generated/pgsql.php",
- "generated/posix.php",
- "generated/ps.php",
- "generated/pspell.php",
- "generated/readline.php",
- "generated/rnp.php",
- "generated/rpminfo.php",
- "generated/rrd.php",
- "generated/sem.php",
- "generated/session.php",
- "generated/shmop.php",
- "generated/sockets.php",
- "generated/sodium.php",
- "generated/solr.php",
- "generated/spl.php",
- "generated/sqlsrv.php",
- "generated/ssdeep.php",
- "generated/ssh2.php",
- "generated/stream.php",
- "generated/strings.php",
- "generated/swoole.php",
- "generated/uodbc.php",
- "generated/uopz.php",
- "generated/url.php",
- "generated/var.php",
- "generated/xdiff.php",
- "generated/xml.php",
- "generated/xmlrpc.php",
- "generated/yaml.php",
- "generated/yaz.php",
- "generated/zip.php",
- "generated/zlib.php"
- ],
- "classmap": [
- "lib/DateTime.php",
- "lib/DateTimeImmutable.php",
- "lib/Exceptions/",
- "generated/Exceptions/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "description": "PHP core functions that throw exceptions instead of returning FALSE on error",
- "support": {
- "issues": "https://github.com/thecodingmachine/safe/issues",
- "source": "https://github.com/thecodingmachine/safe/tree/v3.1.1"
- },
- "funding": [
- {
- "url": "https://github.com/OskarStark",
- "type": "github"
- },
- {
- "url": "https://github.com/shish",
- "type": "github"
- },
- {
- "url": "https://github.com/staabm",
- "type": "github"
- }
- ],
- "time": "2025-04-28T07:56:17+00:00"
- },
{
"name": "theseer/tokenizer",
"version": "1.2.3",