mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Remove all String.trim() from Sieve RainLoop script #1329
This commit is contained in:
parent
bcb6d30023
commit
a2b638dc55
1 changed files with 11 additions and 11 deletions
|
|
@ -17,8 +17,8 @@ function filtersToSieveScript(filters)
|
||||||
''
|
''
|
||||||
];
|
];
|
||||||
|
|
||||||
const quote = string => '"' + string.trim().replace(/(\\|")/g, '\\$1') + '"';
|
const quote = string => '"' + string.replace(/(\\|")/g, '\\$1') + '"';
|
||||||
const StripSpaces = string => string.replace(/\s+/, ' ').trim();
|
const StripSpaces = string => string.replace(/\s+/, ' ');
|
||||||
|
|
||||||
// conditionToSieveScript
|
// conditionToSieveScript
|
||||||
const conditionToString = (condition, require) =>
|
const conditionToString = (condition, require) =>
|
||||||
|
|
@ -26,8 +26,8 @@ function filtersToSieveScript(filters)
|
||||||
let result = '',
|
let result = '',
|
||||||
type = condition.type(),
|
type = condition.type(),
|
||||||
field = condition.field(),
|
field = condition.field(),
|
||||||
value = condition.value().trim(),
|
value = condition.value(),
|
||||||
valueSecond = condition.valueSecond().trim();
|
valueSecond = condition.valueSecond();
|
||||||
|
|
||||||
if (value.length && ('Header' !== field || valueSecond.length)) {
|
if (value.length && ('Header' !== field || valueSecond.length)) {
|
||||||
switch (type)
|
switch (type)
|
||||||
|
|
@ -85,7 +85,7 @@ function filtersToSieveScript(filters)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (('From' === field || 'Recipient' === field) && value.includes(',')) {
|
if (('From' === field || 'Recipient' === field) && value.includes(',')) {
|
||||||
result += ' [' + value.split(',').map(value => quote(value)).join(', ').trim() + ']';
|
result += ' [' + value.split(',').map(value => quote(value)).join(', ') + ']';
|
||||||
} else if ('Size' === field) {
|
} else if ('Size' === field) {
|
||||||
result += ' ' + value;
|
result += ' ' + value;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -130,7 +130,7 @@ function filtersToSieveScript(filters)
|
||||||
result.push(sTab + 'addflag "\\\\Seen";');
|
result.push(sTab + 'addflag "\\\\Seen";');
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = filter.actionValue().trim();
|
let value = filter.actionValue();
|
||||||
value = value.length ? quote(value) : 0;
|
value = value.length ? quote(value) : 0;
|
||||||
switch (filter.actionType())
|
switch (filter.actionType())
|
||||||
{
|
{
|
||||||
|
|
@ -146,21 +146,21 @@ function filtersToSieveScript(filters)
|
||||||
let days = 1,
|
let days = 1,
|
||||||
subject = '',
|
subject = '',
|
||||||
addresses = '',
|
addresses = '',
|
||||||
paramValue = filter.actionValueSecond().trim();
|
paramValue = filter.actionValueSecond();
|
||||||
|
|
||||||
if (paramValue.length) {
|
if (paramValue.length) {
|
||||||
subject = ':subject ' + quote(StripSpaces(paramValue)) + ' ';
|
subject = ':subject ' + quote(StripSpaces(paramValue)) + ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
paramValue = ('' + (filter.actionValueThird() || '')).trim();
|
paramValue = ('' + (filter.actionValueThird() || ''));
|
||||||
if (paramValue.length) {
|
if (paramValue.length) {
|
||||||
days = Math.max(1, parseInt(paramValue, 10));
|
days = Math.max(1, parseInt(paramValue, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
paramValue = ('' + (filter.actionValueFourth() || '')).trim()
|
paramValue = ('' + (filter.actionValueFourth() || ''))
|
||||||
if (paramValue.length) {
|
if (paramValue.length) {
|
||||||
paramValue = paramValue.split(',').map(email =>
|
paramValue = paramValue.split(',').map(email =>
|
||||||
email.trim().length ? quote(email) : ''
|
email.length ? quote(email) : ''
|
||||||
).filter(email => email.length);
|
).filter(email => email.length);
|
||||||
if (paramValue.length) {
|
if (paramValue.length) {
|
||||||
addresses = ':addresses [' + paramValue.join(', ') + '] ';
|
addresses = ':addresses [' + paramValue.join(', ') + '] ';
|
||||||
|
|
@ -286,7 +286,7 @@ export class SieveScriptModel extends AbstractModel
|
||||||
}
|
}
|
||||||
|
|
||||||
verify() {
|
verify() {
|
||||||
this.nameError(!this.name().trim());
|
this.nameError(!this.name());
|
||||||
return !this.nameError();
|
return !this.nameError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue