mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-25 07:16:21 +08: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 StripSpaces = string => string.replace(/\s+/, ' ').trim();
|
||||
const quote = string => '"' + string.replace(/(\\|")/g, '\\$1') + '"';
|
||||
const StripSpaces = string => string.replace(/\s+/, ' ');
|
||||
|
||||
// conditionToSieveScript
|
||||
const conditionToString = (condition, require) =>
|
||||
|
@ -26,8 +26,8 @@ function filtersToSieveScript(filters)
|
|||
let result = '',
|
||||
type = condition.type(),
|
||||
field = condition.field(),
|
||||
value = condition.value().trim(),
|
||||
valueSecond = condition.valueSecond().trim();
|
||||
value = condition.value(),
|
||||
valueSecond = condition.valueSecond();
|
||||
|
||||
if (value.length && ('Header' !== field || valueSecond.length)) {
|
||||
switch (type)
|
||||
|
@ -85,7 +85,7 @@ function filtersToSieveScript(filters)
|
|||
}
|
||||
|
||||
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) {
|
||||
result += ' ' + value;
|
||||
} else {
|
||||
|
@ -130,7 +130,7 @@ function filtersToSieveScript(filters)
|
|||
result.push(sTab + 'addflag "\\\\Seen";');
|
||||
}
|
||||
|
||||
let value = filter.actionValue().trim();
|
||||
let value = filter.actionValue();
|
||||
value = value.length ? quote(value) : 0;
|
||||
switch (filter.actionType())
|
||||
{
|
||||
|
@ -146,21 +146,21 @@ function filtersToSieveScript(filters)
|
|||
let days = 1,
|
||||
subject = '',
|
||||
addresses = '',
|
||||
paramValue = filter.actionValueSecond().trim();
|
||||
paramValue = filter.actionValueSecond();
|
||||
|
||||
if (paramValue.length) {
|
||||
subject = ':subject ' + quote(StripSpaces(paramValue)) + ' ';
|
||||
}
|
||||
|
||||
paramValue = ('' + (filter.actionValueThird() || '')).trim();
|
||||
paramValue = ('' + (filter.actionValueThird() || ''));
|
||||
if (paramValue.length) {
|
||||
days = Math.max(1, parseInt(paramValue, 10));
|
||||
}
|
||||
|
||||
paramValue = ('' + (filter.actionValueFourth() || '')).trim()
|
||||
paramValue = ('' + (filter.actionValueFourth() || ''))
|
||||
if (paramValue.length) {
|
||||
paramValue = paramValue.split(',').map(email =>
|
||||
email.trim().length ? quote(email) : ''
|
||||
email.length ? quote(email) : ''
|
||||
).filter(email => email.length);
|
||||
if (paramValue.length) {
|
||||
addresses = ':addresses [' + paramValue.join(', ') + '] ';
|
||||
|
@ -286,7 +286,7 @@ export class SieveScriptModel extends AbstractModel
|
|||
}
|
||||
|
||||
verify() {
|
||||
this.nameError(!this.name().trim());
|
||||
this.nameError(!this.name());
|
||||
return !this.nameError();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue