mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Clean up request class.
This commit is contained in:
parent
51dfb8ebf1
commit
fe8f5573d2
@ -92,58 +92,7 @@ class Request extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function string(string $field): string
|
public function string(string $field): string
|
||||||
{
|
{
|
||||||
$string = $this->get($field) ?? '';
|
return app('steam')->cleanString($this->get($field) ?? '');
|
||||||
$search = [
|
|
||||||
"\u{0001}", // start of heading
|
|
||||||
"\u{0002}", // start of text
|
|
||||||
"\u{0003}", // end of text
|
|
||||||
"\u{0004}", // end of transmission
|
|
||||||
"\u{0005}", // enquiry
|
|
||||||
"\u{0006}", // ACK
|
|
||||||
"\u{0007}", // BEL
|
|
||||||
"\u{0008}", // backspace
|
|
||||||
"\u{000E}", // shift out
|
|
||||||
"\u{000F}", // shift in
|
|
||||||
"\u{0010}", // data link escape
|
|
||||||
"\u{0011}", // DC1
|
|
||||||
"\u{0012}", // DC2
|
|
||||||
"\u{0013}", // DC3
|
|
||||||
"\u{0014}", // DC4
|
|
||||||
"\u{0015}", // NAK
|
|
||||||
"\u{0016}", // SYN
|
|
||||||
"\u{0017}", // ETB
|
|
||||||
"\u{0018}", // CAN
|
|
||||||
"\u{0019}", // EM
|
|
||||||
"\u{001A}", // SUB
|
|
||||||
"\u{001B}", // escape
|
|
||||||
"\u{001C}", // file separator
|
|
||||||
"\u{001D}", // group separator
|
|
||||||
"\u{001E}", // record separator
|
|
||||||
"\u{001F}", // unit separator
|
|
||||||
"\u{007F}", // DEL
|
|
||||||
"\u{00A0}", // non-breaking space
|
|
||||||
"\u{1680}", // ogham space mark
|
|
||||||
"\u{180E}", // mongolian vowel separator
|
|
||||||
"\u{2000}", // en quad
|
|
||||||
"\u{2001}", // em quad
|
|
||||||
"\u{2002}", // en space
|
|
||||||
"\u{2003}", // em space
|
|
||||||
"\u{2004}", // three-per-em space
|
|
||||||
"\u{2005}", // four-per-em space
|
|
||||||
"\u{2006}", // six-per-em space
|
|
||||||
"\u{2007}", // figure space
|
|
||||||
"\u{2008}", // punctuation space
|
|
||||||
"\u{2009}", // thin space
|
|
||||||
"\u{200A}", // hair space
|
|
||||||
"\u{200B}", // zero width space
|
|
||||||
"\u{202F}", // narrow no-break space
|
|
||||||
"\u{3000}", // ideographic space
|
|
||||||
"\u{FEFF}", // zero width no -break space
|
|
||||||
];
|
|
||||||
$replace = "\x20"; // plain old normal space
|
|
||||||
$string = str_replace($search, $replace, $string);
|
|
||||||
|
|
||||||
return trim($string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +30,6 @@ use FireflyIII\Models\Transaction;
|
|||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,6 +37,7 @@ use stdClass;
|
|||||||
*/
|
*/
|
||||||
class Steam
|
class Steam
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \FireflyIII\Models\Account $account
|
* @param \FireflyIII\Models\Account $account
|
||||||
* @param \Carbon\Carbon $date
|
* @param \Carbon\Carbon $date
|
||||||
@ -315,6 +315,68 @@ class Steam
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove weird chars from strings.
|
||||||
|
*
|
||||||
|
* @param string $string
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function cleanString(string $string): string
|
||||||
|
{
|
||||||
|
$search = [
|
||||||
|
"\u{0001}", // start of heading
|
||||||
|
"\u{0002}", // start of text
|
||||||
|
"\u{0003}", // end of text
|
||||||
|
"\u{0004}", // end of transmission
|
||||||
|
"\u{0005}", // enquiry
|
||||||
|
"\u{0006}", // ACK
|
||||||
|
"\u{0007}", // BEL
|
||||||
|
"\u{0008}", // backspace
|
||||||
|
"\u{000E}", // shift out
|
||||||
|
"\u{000F}", // shift in
|
||||||
|
"\u{0010}", // data link escape
|
||||||
|
"\u{0011}", // DC1
|
||||||
|
"\u{0012}", // DC2
|
||||||
|
"\u{0013}", // DC3
|
||||||
|
"\u{0014}", // DC4
|
||||||
|
"\u{0015}", // NAK
|
||||||
|
"\u{0016}", // SYN
|
||||||
|
"\u{0017}", // ETB
|
||||||
|
"\u{0018}", // CAN
|
||||||
|
"\u{0019}", // EM
|
||||||
|
"\u{001A}", // SUB
|
||||||
|
"\u{001B}", // escape
|
||||||
|
"\u{001C}", // file separator
|
||||||
|
"\u{001D}", // group separator
|
||||||
|
"\u{001E}", // record separator
|
||||||
|
"\u{001F}", // unit separator
|
||||||
|
"\u{007F}", // DEL
|
||||||
|
"\u{00A0}", // non-breaking space
|
||||||
|
"\u{1680}", // ogham space mark
|
||||||
|
"\u{180E}", // mongolian vowel separator
|
||||||
|
"\u{2000}", // en quad
|
||||||
|
"\u{2001}", // em quad
|
||||||
|
"\u{2002}", // en space
|
||||||
|
"\u{2003}", // em space
|
||||||
|
"\u{2004}", // three-per-em space
|
||||||
|
"\u{2005}", // four-per-em space
|
||||||
|
"\u{2006}", // six-per-em space
|
||||||
|
"\u{2007}", // figure space
|
||||||
|
"\u{2008}", // punctuation space
|
||||||
|
"\u{2009}", // thin space
|
||||||
|
"\u{200A}", // hair space
|
||||||
|
"\u{200B}", // zero width space
|
||||||
|
"\u{202F}", // narrow no-break space
|
||||||
|
"\u{3000}", // ideographic space
|
||||||
|
"\u{FEFF}", // zero width no -break space
|
||||||
|
];
|
||||||
|
$replace = "\x20"; // plain old normal space
|
||||||
|
$string = str_replace($search, $replace, $string);
|
||||||
|
|
||||||
|
return trim($string);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $isEncrypted
|
* @param int $isEncrypted
|
||||||
* @param $value
|
* @param $value
|
||||||
|
Loading…
Reference in New Issue
Block a user