From 8fd64791d620410afbe144d5f169de5c9bd0aa83 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 23 Sep 2018 06:53:15 +0200 Subject: [PATCH] Strip newlines and tabs from description. --- app/Factory/TransactionJournalFactory.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index f57af20e70..da8a3ffbc1 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -36,6 +36,11 @@ use Log; */ class TransactionJournalFactory { + /** @var User The user */ + private $user; + + use JournalServiceTrait, TransactionTypeTrait; + /** * Constructor. */ @@ -46,10 +51,6 @@ class TransactionJournalFactory } } - use JournalServiceTrait, TransactionTypeTrait; - /** @var User The user */ - private $user; - /** * Store a new transaction journal. * @@ -67,13 +68,15 @@ class TransactionJournalFactory $type = $this->findTransactionType($data['type']); $defaultCurrency = app('amount')->getDefaultCurrencyByUser($this->user); Log::debug(sprintf('Going to store a %s', $type->type)); - $journal = TransactionJournal::create( + $description = app('steam')->cleanString($data['description']); + $description = str_replace(["\n", "\t", "\r"], "\x20", $description); + $journal = TransactionJournal::create( [ 'user_id' => $data['user'], 'transaction_type_id' => $type->id, 'bill_id' => null, 'transaction_currency_id' => $defaultCurrency->id, - 'description' => $data['description'], + 'description' => $description, 'date' => $data['date']->format('Y-m-d'), 'order' => 0, 'tag_count' => 0, @@ -114,7 +117,7 @@ class TransactionJournalFactory // store date meta fields (if present): $fields = ['sepa-cc', 'sepa-ct-op', 'sepa-ct-id', 'sepa-db', 'sepa-country', 'sepa-ep', 'sepa-ci', 'interest_date', 'book_date', 'process_date', 'due_date', 'recurrence_id', 'payment_date', 'invoice_date', 'internal_reference', 'bunq_payment_id', 'importHash', 'importHashV2', - 'external_id', 'sepa-batch-id','original-source']; + 'external_id', 'sepa-batch-id', 'original-source']; foreach ($fields as $field) { $this->storeMeta($journal, $data, $field);