mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Replace methods with safe variants. Let's see how this works out.
This commit is contained in:
@@ -69,7 +69,7 @@ class RemoteUserGuard implements Guard
|
||||
|
||||
if (function_exists('apache_request_headers')) {
|
||||
Log::debug('Use apache_request_headers to find user ID.');
|
||||
$userID = request()->server($header) ?? apache_request_headers()[$header] ?? null;
|
||||
$userID = request()->server($header) ?? \Safe\apache_request_headers()[$header] ?? null;
|
||||
}
|
||||
|
||||
if (null === $userID || '' === $userID) {
|
||||
@@ -87,7 +87,7 @@ class RemoteUserGuard implements Guard
|
||||
$header = config('auth.guard_email');
|
||||
|
||||
if (null !== $header) {
|
||||
$emailAddress = (string) (request()->server($header) ?? apache_request_headers()[$header] ?? null);
|
||||
$emailAddress = (string) (request()->server($header) ?? \Safe\apache_request_headers()[$header] ?? null);
|
||||
$preference = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email');
|
||||
|
||||
if ('' !== $emailAddress && null === $preference && $emailAddress !== $userID) {
|
||||
|
||||
@@ -78,7 +78,7 @@ class CacheProperties
|
||||
$content = '';
|
||||
foreach ($this->properties as $property) {
|
||||
try {
|
||||
$content .= json_encode($property, JSON_THROW_ON_ERROR);
|
||||
$content .= \Safe\json_encode($property, JSON_THROW_ON_ERROR);
|
||||
} catch (\JsonException $e) {
|
||||
// @ignoreException
|
||||
$content .= hash('sha256', (string) time());
|
||||
|
||||
@@ -63,7 +63,7 @@ class UpdateCheckCronjob extends AbstractCronjob
|
||||
$this->jobFired = false;
|
||||
$this->jobErrored = false;
|
||||
$this->jobSucceeded = true;
|
||||
$this->message = sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data));
|
||||
$this->message = sprintf('Checked for updates less than a week ago (on %s).', \Safe\date('Y-m-d H:i:s', $lastCheckTime->data));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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'] ?? '';
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -270,8 +270,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);
|
||||
}
|
||||
@@ -549,8 +549,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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -240,8 +240,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));
|
||||
}
|
||||
@@ -272,7 +272,7 @@ class General extends AbstractExtension
|
||||
return new TwigFunction(
|
||||
'phpdate',
|
||||
static function (string $str): string {
|
||||
return date($str);
|
||||
return \Safe\date($str);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -254,7 +254,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));
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -275,7 +275,7 @@ class TransactionGroupTwig extends AbstractExtension
|
||||
return '';
|
||||
}
|
||||
|
||||
return json_decode($entry->data, true);
|
||||
return \Safe\json_decode($entry->data, true);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user