mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Fix #2628
This commit is contained in:
@@ -49,6 +49,8 @@ class TransactionUpdateRequest extends Request
|
|||||||
private $integerFields;
|
private $integerFields;
|
||||||
/** @var array Fields that contain string values. */
|
/** @var array Fields that contain string values. */
|
||||||
private $stringFields;
|
private $stringFields;
|
||||||
|
/** @var array Fields that contain text (with newlines) */
|
||||||
|
private $textareaFields;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authorize logged in users.
|
* Authorize logged in users.
|
||||||
@@ -91,6 +93,10 @@ class TransactionUpdateRequest extends Request
|
|||||||
'invoice_date',
|
'invoice_date',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->textareaFields = [
|
||||||
|
'notes',
|
||||||
|
];
|
||||||
|
|
||||||
$this->stringFields = [
|
$this->stringFields = [
|
||||||
'type',
|
'type',
|
||||||
'currency_code',
|
'currency_code',
|
||||||
@@ -103,7 +109,6 @@ class TransactionUpdateRequest extends Request
|
|||||||
'budget_name',
|
'budget_name',
|
||||||
'category_name',
|
'category_name',
|
||||||
'bill_name',
|
'bill_name',
|
||||||
'notes',
|
|
||||||
'internal_reference',
|
'internal_reference',
|
||||||
'external_id',
|
'external_id',
|
||||||
'bunq_payment_id',
|
'bunq_payment_id',
|
||||||
@@ -296,6 +301,12 @@ class TransactionUpdateRequest extends Request
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($this->textareaFields as $fieldName) {
|
||||||
|
if (array_key_exists($fieldName, $transaction)) {
|
||||||
|
$current[$fieldName] = $this->nlStringFromValue((string)$transaction[$fieldName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->dateFields as $fieldName) {
|
foreach ($this->dateFields as $fieldName) {
|
||||||
Log::debug(sprintf('Now at date field %s', $fieldName));
|
Log::debug(sprintf('Now at date field %s', $fieldName));
|
||||||
if (array_key_exists($fieldName, $transaction)) {
|
if (array_key_exists($fieldName, $transaction)) {
|
||||||
|
@@ -125,8 +125,8 @@ class EditController extends Controller
|
|||||||
public function update(RuleGroupFormRequest $request, RuleGroup $ruleGroup)
|
public function update(RuleGroupFormRequest $request, RuleGroup $ruleGroup)
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'title' => $request->input('title'),
|
'title' => $request->string('title'),
|
||||||
'description' => $request->input('description'),
|
'description' => $request->nlString('description'),
|
||||||
'active' => 1 === (int)$request->input('active'),
|
'active' => 1 === (int)$request->input('active'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -56,7 +56,7 @@ class BillFormRequest extends Request
|
|||||||
'date' => $this->date('date'),
|
'date' => $this->date('date'),
|
||||||
'repeat_freq' => $this->string('repeat_freq'),
|
'repeat_freq' => $this->string('repeat_freq'),
|
||||||
'skip' => $this->integer('skip'),
|
'skip' => $this->integer('skip'),
|
||||||
'notes' => $this->string('notes'),
|
'notes' => $this->nlString('notes'),
|
||||||
'active' => $this->boolean('active'),
|
'active' => $this->boolean('active'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@@ -224,6 +224,19 @@ class Request extends FormRequest
|
|||||||
return app('steam')->cleanString((string)($this->get($field) ?? ''));
|
return app('steam')->cleanString((string)($this->get($field) ?? ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return string value, but keep newlines.
|
||||||
|
*
|
||||||
|
* @param string $field
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function nlString(string $field): string
|
||||||
|
{
|
||||||
|
return app('steam')->nlCleanString((string)($this->get($field) ?? ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse and clean a string.
|
* Parse and clean a string.
|
||||||
*
|
*
|
||||||
@@ -242,6 +255,24 @@ class Request extends FormRequest
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse and clean a string, but keep the newlines.
|
||||||
|
*
|
||||||
|
* @param string|null $string
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function nlStringFromValue(?string $string): ?string
|
||||||
|
{
|
||||||
|
if (null === $string) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$result = app('steam')->nlCleanString($string);
|
||||||
|
|
||||||
|
return '' === $result ? null : $result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return date or NULL.
|
* Return date or NULL.
|
||||||
*
|
*
|
||||||
|
@@ -53,7 +53,7 @@ class RuleFormRequest extends Request
|
|||||||
'rule_group_id' => $this->integer('rule_group_id'),
|
'rule_group_id' => $this->integer('rule_group_id'),
|
||||||
'active' => $this->boolean('active'),
|
'active' => $this->boolean('active'),
|
||||||
'trigger' => $this->string('trigger'),
|
'trigger' => $this->string('trigger'),
|
||||||
'description' => $this->string('description'),
|
'description' => $this->nlString('description'),
|
||||||
'stop_processing' => $this->boolean('stop_processing'),
|
'stop_processing' => $this->boolean('stop_processing'),
|
||||||
'strict' => $this->boolean('strict'),
|
'strict' => $this->boolean('strict'),
|
||||||
'triggers' => $this->getRuleTriggerData(),
|
'triggers' => $this->getRuleTriggerData(),
|
||||||
|
@@ -55,7 +55,7 @@ class RuleGroupFormRequest extends Request
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'title' => $this->string('title'),
|
'title' => $this->string('title'),
|
||||||
'description' => $this->string('description'),
|
'description' => $this->nlString('description'),
|
||||||
'active' => $active,
|
'active' => $active,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@@ -389,6 +389,69 @@ class Steam
|
|||||||
return trim($string);
|
return trim($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove weird chars from strings, but keep newlines and tabs.
|
||||||
|
*
|
||||||
|
* @param string $string
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function nlCleanString(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);
|
||||||
|
$string = str_replace("\r", '', $string);
|
||||||
|
|
||||||
|
return trim($string);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $accounts
|
* @param array $accounts
|
||||||
*
|
*
|
||||||
|
2
public/v1/js/app.js
vendored
2
public/v1/js/app.js
vendored
File diff suppressed because one or more lines are too long
@@ -29,7 +29,9 @@
|
|||||||
<textarea class="form-control" :name="name"
|
<textarea class="form-control" :name="name"
|
||||||
:title="title" autocomplete="off"
|
:title="title" autocomplete="off"
|
||||||
ref="str"
|
ref="str"
|
||||||
:value="value" @input="handleInput"
|
rows="8"
|
||||||
|
v-model="textValue"
|
||||||
|
@input="handleInput"
|
||||||
:placeholder="title"></textarea>
|
:placeholder="title"></textarea>
|
||||||
<ul class="list-unstyled" v-for="error in this.error">
|
<ul class="list-unstyled" v-for="error in this.error">
|
||||||
<li class="text-danger">{{ error }}</li>
|
<li class="text-danger">{{ error }}</li>
|
||||||
@@ -47,6 +49,11 @@
|
|||||||
value: String,
|
value: String,
|
||||||
error: Array
|
error: Array
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
textValue: this.value,
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleInput(e) {
|
handleInput(e) {
|
||||||
this.$emit('input', this.$refs.str.value);
|
this.$emit('input', this.$refs.str.value);
|
||||||
|
Reference in New Issue
Block a user