Always allow raw editing of Sieve scripts

This commit is contained in:
djmaze 2021-01-21 10:00:12 +01:00
parent 3ed7b53f68
commit 14ba459d46
20 changed files with 59 additions and 211 deletions

View file

@ -3,6 +3,8 @@ import ko from 'ko';
import { AbstractModel } from 'Knoin/AbstractModel';
import { FilterModel } from 'Model/Filter';
const SIEVE_FILE_NAME = 'rainloop.user';
// collectionToFileString
function filtersToSieveScript(filters)
{
@ -311,7 +313,7 @@ class SieveScriptModel extends AbstractModel
* Only 'rainloop.user' script supports filters
*/
allowFilters() {
return 'rainloop.user' === this.name();
return SIEVE_FILE_NAME === this.name();
}
/**
@ -331,7 +333,7 @@ class SieveScriptModel extends AbstractModel
} else {
script.filters([]);
}
script.canBeDeleted(0 !== json.name.indexOf('rainloop.user'));
script.canBeDeleted(SIEVE_FILE_NAME !== json.name);
script.exists(true);
script.hasChanges(false);
}

View file

@ -161,83 +161,47 @@ class RemoteAdminFetch extends AbstractFetchRemote {
});
}
createOrUpdateDomain(
fCallback,
bCreate,
sName,
sIncHost,
iIncPort,
sIncSecure,
bIncShortLogin,
bUseSieve,
sSieveAllowRaw,
sSieveHost,
iSievePort,
sSieveSecure,
sOutHost,
iOutPort,
sOutSecure,
bOutShortLogin,
bOutAuth,
bOutPhpMail,
sWhiteList
) {
createOrUpdateDomain(fCallback, oDomain) {
this.defaultRequest(fCallback, 'AdminDomainSave', {
Create: bCreate ? 1 : 0,
Name: sName,
Create: oDomain.edit() ? 0 : 1,
Name: oDomain.name(),
IncHost: sIncHost,
IncPort: iIncPort,
IncSecure: sIncSecure,
IncShortLogin: bIncShortLogin ? 1 : 0,
IncHost: oDomain.imapServer(),
IncPort: oDomain.imapPort(),
IncSecure: oDomain.imapSecure(),
IncShortLogin: oDomain.imapShortLogin() ? 1 : 0,
UseSieve: bUseSieve ? 1 : 0,
SieveAllowRaw: sSieveAllowRaw ? 1 : 0,
SieveHost: sSieveHost,
SievePort: iSievePort,
SieveSecure: sSieveSecure,
UseSieve: oDomain.useSieve() ? 1 : 0,
SieveHost: oDomain.sieveServer(),
SievePort: oDomain.sievePort(),
SieveSecure: oDomain.sieveSecure(),
OutHost: sOutHost,
OutPort: iOutPort,
OutSecure: sOutSecure,
OutShortLogin: bOutShortLogin ? 1 : 0,
OutAuth: bOutAuth ? 1 : 0,
OutUsePhpMail: bOutPhpMail ? 1 : 0,
OutHost: oDomain.smtpServer(),
OutPort: oDomain.smtpPort(),
OutSecure: oDomain.smtpSecure(),
OutShortLogin: oDomain.smtpShortLogin() ? 1 : 0,
OutAuth: oDomain.smtpAuth() ? 1 : 0,
OutUsePhpMail: oDomain.smtpPhpMail() ? 1 : 0,
WhiteList: sWhiteList
WhiteList: oDomain.whiteList()
});
}
testConnectionForDomain(
fCallback,
sName,
sIncHost,
iIncPort,
sIncSecure,
bUseSieve,
sSieveHost,
iSievePort,
sSieveSecure,
sOutHost,
iOutPort,
sOutSecure,
bOutAuth,
bOutPhpMail
) {
testConnectionForDomain(fCallback, oDomain) {
this.defaultRequest(fCallback, 'AdminDomainTest', {
Name: sName,
IncHost: sIncHost,
IncPort: iIncPort,
IncSecure: sIncSecure,
UseSieve: bUseSieve ? 1 : 0,
SieveHost: sSieveHost,
SievePort: iSievePort,
SieveSecure: sSieveSecure,
OutHost: sOutHost,
OutPort: iOutPort,
OutSecure: sOutSecure,
OutAuth: bOutAuth ? 1 : 0,
OutUsePhpMail: bOutPhpMail ? 1 : 0
Name: oDomain.name(),
IncHost: oDomain.imapServer(),
IncPort: oDomain.imapPort(),
IncSecure: oDomain.imapSecure(),
UseSieve: oDomain.useSieve() ? 1 : 0,
SieveHost: oDomain.sieveServer(),
SievePort: oDomain.sievePort(),
SieveSecure: oDomain.sieveSecure(),
OutHost: oDomain.smtpServer(),
OutPort: oDomain.smtpPort(),
OutSecure: oDomain.smtpSecure(),
OutAuth: oDomain.smtpAuth() ? 1 : 0,
OutUsePhpMail: oDomain.smtpPhpMail() ? 1 : 0
});
}

View file

@ -44,7 +44,6 @@ class DomainPopupView extends AbstractViewNext {
imapSecure: ServerSecure.None,
imapShortLogin: false,
useSieve: false,
sieveAllowRaw: false,
sieveServer: '',
sievePort: '4190',
sieveSecure: ServerSecure.None,
@ -174,28 +173,7 @@ class DomainPopupView extends AbstractViewNext {
this.saving(true);
Remote.createOrUpdateDomain(
this.onDomainCreateOrSaveResponse.bind(this),
!this.edit(),
this.name(),
this.imapServer(),
pInt(this.imapPort()),
this.imapSecure(),
this.imapShortLogin(),
this.useSieve(),
this.sieveAllowRaw(),
this.sieveServer(),
pInt(this.sievePort()),
this.sieveSecure(),
this.smtpServer(),
pInt(this.smtpPort()),
this.smtpSecure(),
this.smtpShortLogin(),
this.smtpAuth(),
this.smtpPhpMail(),
this.whiteList()
this
);
}
@ -211,22 +189,7 @@ class DomainPopupView extends AbstractViewNext {
Remote.testConnectionForDomain(
this.onTestConnectionResponse.bind(this),
this.name(),
this.imapServer(),
pInt(this.imapPort()),
this.imapSecure(),
this.useSieve(),
this.sieveServer(),
pInt(this.sievePort()),
this.sieveSecure(),
this.smtpServer(),
pInt(this.smtpPort()),
this.smtpSecure(),
this.smtpAuth(),
this.smtpPhpMail()
this
);
}
@ -336,7 +299,6 @@ class DomainPopupView extends AbstractViewNext {
this.imapSecure(oDomain.IncSecure);
this.imapShortLogin(!!oDomain.IncShortLogin);
this.useSieve(!!oDomain.UseSieve);
this.sieveAllowRaw(!!oDomain.SieveAllowRaw);
this.sieveServer(oDomain.SieveHost);
this.sievePort('' + pInt(oDomain.SievePort));
this.sieveSecure(oDomain.SieveSecure);
@ -371,7 +333,6 @@ class DomainPopupView extends AbstractViewNext {
this.imapShortLogin(false);
this.useSieve(false);
this.sieveAllowRaw(false);
this.sieveServer('');
this.sievePort('4190');
this.sieveSecure(ServerSecure.None);

View file

@ -25,8 +25,6 @@ class FilterPopupView extends AbstractViewNext {
selectedFolderValue: ''
});
this.modules = SieveStore.capa;
this.fTrueCallback = null;
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
@ -34,15 +32,13 @@ class FilterPopupView extends AbstractViewNext {
this.selectedFolderValue.subscribe(() => this.filter() && this.filter().actionValueError(false));
this.actionTypeOptions = ko.observableArray([]);
this.fieldOptions = ko.observableArray([]);
this.typeOptions = ko.observableArray([]);
this.typeOptionsSize = ko.observableArray([]);
this.typeOptionsBody = ko.observableArray([]);
['actionTypeOptions','fieldOptions','typeOptions','typeOptionsSize','typeOptionsBody'].forEach(
key => this[key] = ko.observableArray([])
);
initOnStartOrLangChange(this.populateOptions.bind(this));
this.modules.subscribe(this.populateOptions, this);
SieveStore.capa.subscribe(this.populateOptions, this);
}
@command()
@ -84,7 +80,7 @@ class FilterPopupView extends AbstractViewNext {
// this.actionTypeOptions.push({'id': FiltersAction.None,
// 'name': i18n('POPUPS_FILTER/SELECT_ACTION_NONE')});
const modules = this.modules();
const modules = SieveStore.capa();
if (modules) {
if (modules.includes('imap4flags')) {
this.allowMarkAsRead(true);

View file

@ -34,8 +34,7 @@ trait Filters
return $this->DefaultResponse(__FUNCTION__, $aFakeFilters);
}
return $this->DefaultResponse(__FUNCTION__,
$this->FiltersProvider()->Load($oAccount, $oAccount->DomainSieveAllowRaw()));
return $this->DefaultResponse(__FUNCTION__, $this->FiltersProvider()->Load($oAccount));
}
/**

View file

@ -351,7 +351,6 @@ Enables caching in the system'),
'smtp_show_server_errors' => array(false),
'smtp_use_auth_plain' => array(true),
'smtp_use_auth_cram_md5' => array(false),
'sieve_allow_raw_script' => array(false),
'sieve_utf8_folder_name' => array(true),
'sieve_auth_plain_initial' => array(true),
'sieve_allow_fileinto_inbox' => array(false),

View file

@ -226,11 +226,6 @@ class Account
return $this->Domain()->SieveSecure();
}
public function DomainSieveAllowRaw() : bool
{
return $this->Domain()->SieveAllowRaw();
}
public function GetAuthToken() : string
{
return \RainLoop\Utils::EncodeKeyValues(array(

View file

@ -83,11 +83,6 @@ class Domain implements \JsonSerializable
*/
private $iSieveSecure;
/**
* @var bool
*/
private $bSieveAllowRaw;
/**
* @var string
*/
@ -122,8 +117,6 @@ class Domain implements \JsonSerializable
$this->iSievePort = $iSievePort;
$this->iSieveSecure = $iSieveSecure;
$this->bSieveAllowRaw = false;
$this->sWhiteList = \trim($sWhiteList);
$this->sAliasName = '';
}
@ -140,7 +133,6 @@ class Domain implements \JsonSerializable
!empty($aDomain['imap_secure']) ? $aDomain['imap_secure'] : '');
$bUseSieve = !empty($aDomain['sieve_use']);
$bSieveAllowRaw = !empty($aDomain['sieve_allow_raw']);
$sSieveHost = empty($aDomain['sieve_host']) ? '' : (string) $aDomain['sieve_host'];
$iSievePort = empty($aDomain['sieve_port']) ? 4190 : (int) $aDomain['sieve_port'];
@ -164,8 +156,6 @@ class Domain implements \JsonSerializable
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList);
$oDomain->SetSieveAllowRaw($bSieveAllowRaw);
}
return $oDomain;
@ -208,7 +198,6 @@ class Domain implements \JsonSerializable
'imap_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iIncSecure).'"',
'imap_short_login = '.($this->bIncShortLogin ? 'On' : 'Off'),
'sieve_use = '.($this->bUseSieve ? 'On' : 'Off'),
'sieve_allow_raw = '.($this->bSieveAllowRaw ? 'On' : 'Off'),
'sieve_host = "'.$this->encodeIniString($this->sSieveHost).'"',
'sieve_port = '.$this->iSievePort,
'sieve_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iSieveSecure).'"',
@ -326,16 +315,6 @@ class Domain implements \JsonSerializable
return $this->iSieveSecure;
}
public function SieveAllowRaw() : bool
{
return $this->bSieveAllowRaw;
}
public function SetSieveAllowRaw(bool $bSieveAllowRaw)
{
$this->bSieveAllowRaw = $bSieveAllowRaw;
}
public function OutHost() : string
{
return $this->sOutHost;
@ -413,7 +392,6 @@ class Domain implements \JsonSerializable
'SieveHost' => $this->SieveHost(),
'SievePort' => $this->SievePort(),
'SieveSecure' => $this->SieveSecure(),
'SieveAllowRaw' => $this->SieveAllowRaw(),
'OutHost' => $this->OutHost(),
'OutPort' => $this->OutPort(),
'OutSecure' => $this->OutSecure(),
@ -438,7 +416,6 @@ class Domain implements \JsonSerializable
'SieveHost' => \MailSo\Base\Utils::IdnToUtf8($this->SieveHost()),
'SievePort' => $this->SievePort(),
'SieveSecure' => $this->SieveSecure(),
'SieveAllowRaw' => $this->SieveAllowRaw(),
'OutHost' => \MailSo\Base\Utils::IdnToUtf8($this->OutHost()),
'OutPort' => $this->OutPort(),
'OutSecure' => $this->OutSecure(),

View file

@ -103,7 +103,6 @@ class Domain extends AbstractProvider
$iIncSecure = (int) $oActions->GetActionParam('IncSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$bIncShortLogin = '1' === (string) $oActions->GetActionParam('IncShortLogin', '0');
$bUseSieve = '1' === (string) $oActions->GetActionParam('UseSieve', '0');
$bSieveAllowRaw = '1' === (string) $oActions->GetActionParam('SieveAllowRaw', '0');
$sSieveHost = (string) $oActions->GetActionParam('SieveHost', '');
$iSievePort = (int) $oActions->GetActionParam('SievePort', 4190);
$iSieveSecure = (int) $oActions->GetActionParam('SieveSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
@ -147,11 +146,6 @@ class Domain extends AbstractProvider
$sWhiteList);
}
}
if ($oDomain)
{
$oDomain->SetSieveAllowRaw($bSieveAllowRaw);
}
}
return $oDomain;
@ -170,7 +164,6 @@ class Domain extends AbstractProvider
$iIncSecure = (int) $oActions->GetActionParam('IncSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$bIncShortLogin = '1' === (string) $oActions->GetActionParam('IncShortLogin', '0');
$bUseSieve = '1' === (string) $oActions->GetActionParam('UseSieve', '0');
$bSieveAllowRaw = '1' === (string) $oActions->GetActionParam('SieveAllowRaw', '0');
$sSieveHost = (string) $oActions->GetActionParam('SieveHost', '');
$iSievePort = (int) $oActions->GetActionParam('SievePort', 4190);
$iSieveSecure = (int) $oActions->GetActionParam('SieveSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
@ -214,11 +207,6 @@ class Domain extends AbstractProvider
$sWhiteList);
}
}
if ($oDomain)
{
$oDomain->SetSieveAllowRaw($bSieveAllowRaw);
}
}
return $oDomain;

View file

@ -29,11 +29,11 @@ class Filters extends \RainLoop\Providers\AbstractProvider
throw new \RainLoop\Exceptions\ClientException($defNotification, $oException);
}
public function Load(\RainLoop\Model\Account $oAccount, bool $bAllowRaw = false) : array
public function Load(\RainLoop\Model\Account $oAccount) : array
{
try
{
return $this->IsActive() ? $this->oDriver->Load($oAccount, $bAllowRaw) : array();
return $this->IsActive() ? $this->oDriver->Load($oAccount) : array();
}
catch (\Throwable $oException)
{

View file

@ -4,7 +4,7 @@ namespace RainLoop\Providers\Filters;
interface FiltersInterface
{
public function Load(\RainLoop\Model\Account $oAccount, bool $bAllowRaw = false) : array;
public function Load(\RainLoop\Model\Account $oAccount) : array;
public function Save(\RainLoop\Model\Account $oAccount, string $sScriptName, array $aFilters, string $sRaw = '') : bool;

View file

@ -5,7 +5,6 @@ namespace RainLoop\Providers\Filters;
class SieveStorage implements FiltersInterface
{
const SIEVE_FILE_NAME = 'rainloop.user';
const SIEVE_FILE_NAME_RAW = 'rainloop.user.raw';
/**
* @var \MailSo\Log\Logger
@ -40,7 +39,7 @@ class SieveStorage implements FiltersInterface
: null;
}
public function Load(\RainLoop\Model\Account $oAccount, bool $bAllowRaw = false) : array
public function Load(\RainLoop\Model\Account $oAccount) : array
{
$aModules = array();
$aScripts = array();
@ -53,14 +52,12 @@ class SieveStorage implements FiltersInterface
$aList = $oSieveClient->ListScripts();
foreach ($aList as $name => $active) {
if ($bAllowRaw || $name == self::SIEVE_FILE_NAME) {
$aScripts[$name] = array(
'@Object' => 'Object/SieveScript',
'name' => $name,
'active' => $active,
'body' => $oSieveClient->GetScript($name)
);
}
$aScripts[$name] = array(
'@Object' => 'Object/SieveScript',
'name' => $name,
'active' => $active,
'body' => $oSieveClient->GetScript($name)
);
}
$oSieveClient->LogoutAndDisconnect();
@ -74,15 +71,6 @@ class SieveStorage implements FiltersInterface
'filters' => []
);
}
if ($bAllowRaw && !isset($aList[self::SIEVE_FILE_NAME_RAW])) {
$aScripts[self::SIEVE_FILE_NAME_RAW] = array(
'@Object' => 'Object/SieveScript',
'name' => self::SIEVE_FILE_NAME_RAW,
'active' => false,
'body' => ''
);
}
}
\ksort($aScripts);

View file

@ -131,7 +131,6 @@ en:
SECURE_OPTION_SSL: "SSL/TLS"
SECURE_OPTION_STARTTLS: "STARTTLS"
LABEL_ALLOW_SIEVE_SCRIPTS: "Allow sieve scripts"
LABEL_ALLOW_USER_SCRIPT: "Allow custom user script"
LABEL_USE_SHORT_LOGIN: "Use short login"
LABEL_USE_AUTH: "Use authentication"
LABEL_USE_PHP_MAIL: "Use php mail() function"

View file

@ -127,7 +127,6 @@ de_DE:
SECURE_OPTION_SSL: "SSL/TLS"
SECURE_OPTION_STARTTLS: "STARTTLS"
LABEL_ALLOW_SIEVE_SCRIPTS: "Sieve-Skripte erlauben"
LABEL_ALLOW_USER_SCRIPT: "Benutzerdefiniertes Skript erlauben"
LABEL_USE_SHORT_LOGIN: "Kurze Benutzernamen verwenden"
LABEL_USE_AUTH: "Authentifizierung verwenden"
LABEL_USE_PHP_MAIL: "PHPs mail()-Funktion verwenden"

View file

@ -128,7 +128,6 @@ en_US:
SECURE_OPTION_SSL: "SSL/TLS"
SECURE_OPTION_STARTTLS: "STARTTLS"
LABEL_ALLOW_SIEVE_SCRIPTS: "Allow sieve scripts"
LABEL_ALLOW_USER_SCRIPT: "Allow custom user script"
LABEL_USE_SHORT_LOGIN: "Use short login"
LABEL_USE_AUTH: "Use authentication"
LABEL_USE_PHP_MAIL: "Use php mail() function"

View file

@ -128,7 +128,6 @@ es_ES:
SECURE_OPTION_SSL: "SSL/TLS"
SECURE_OPTION_STARTTLS: "STARTTLS"
LABEL_ALLOW_SIEVE_SCRIPTS: "Permitir scripts de filtro"
LABEL_ALLOW_USER_SCRIPT: "Permitir scripts propios"
LABEL_USE_SHORT_LOGIN: "Inicio de Sesión corto"
LABEL_USE_AUTH: "Usar autenticación"
LABEL_USE_PHP_MAIL: "Utilizar la función mail() de PHP"

View file

@ -128,7 +128,6 @@ fr_FR:
SECURE_OPTION_SSL: "SSL/TLS"
SECURE_OPTION_STARTTLS: "STARTTLS"
LABEL_ALLOW_SIEVE_SCRIPTS: "Autoriser les scripts sieve"
LABEL_ALLOW_USER_SCRIPT: "Autoriser les scripts personnels"
LABEL_USE_SHORT_LOGIN: "Utiliser l'identifiant court"
LABEL_USE_AUTH: "Utiliser l'authentification"
LABEL_USE_PHP_MAIL: "Utiliser la fonction mail() de php"

View file

@ -127,7 +127,6 @@ nl_NL:
SECURE_OPTION_SSL: "SSL/TLS"
SECURE_OPTION_STARTTLS: "STARTTLS"
LABEL_ALLOW_SIEVE_SCRIPTS: "Sta Sieve scripts toe"
LABEL_ALLOW_USER_SCRIPT: "Sta gebruiker scripts toe"
LABEL_USE_SHORT_LOGIN: "Gebruik verkorte login"
LABEL_USE_AUTH: "Gebruik authenticatie"
LABEL_USE_PHP_MAIL: "Gebruik php mail() functie"

View file

@ -129,7 +129,6 @@ zh_CN:
SECURE_OPTION_SSL: "SSL/TLS"
SECURE_OPTION_STARTTLS: "STARTTLS"
LABEL_ALLOW_SIEVE_SCRIPTS: "可使用筛选脚本"
LABEL_ALLOW_USER_SCRIPT: "允许用户自定义脚本"
LABEL_USE_SHORT_LOGIN: "使用短用户名登录"
LABEL_USE_AUTH: "使用认证"
LABEL_USE_PHP_MAIL: "使用 php mail() 函数"

View file

@ -42,10 +42,10 @@
<input type="text" class="span3" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: imapServer, hasfocus: imapServerFocus" />
</div>
<div class="span1">
<div class="span2">
<span data-i18n="POPUPS_DOMAIN/LABEL_PORT"></span>
<br />
<input type="text" class="span1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
<input type="number" class="span1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: imapPort" />
</div>
</div>
@ -84,8 +84,6 @@
<i class="icon-filter"></i>
&nbsp;
<a href="#" class="g-ui-link" data-i18n="POPUPS_DOMAIN/BUTTON_SIEVE_CONFIGURATION"></a>
&nbsp;&nbsp;
<span style="color:red">(<span data-i18n="HINTS/BETA"></span>)</span>
</span>
</div>
</div>
@ -103,18 +101,6 @@
</div>
</div>
<div data-bind="visible: useSieve">
<div class="row">
<div class="span5">
<div data-bind="component: {
name: 'Checkbox',
params: {
label: 'POPUPS_DOMAIN/LABEL_ALLOW_USER_SCRIPT',
value: sieveAllowRaw
}
}"></div>
</div>
</div>
<br />
<div class="row">
<div class="span3">
<span data-i18n="POPUPS_DOMAIN/LABEL_SERVER"></span>
@ -125,7 +111,7 @@
<div class="span1">
<span data-i18n="POPUPS_DOMAIN/LABEL_PORT"></span>
<br />
<input type="text" class="span1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
<input type="number" class="span2" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: sievePort" />
</div>
</div>
@ -168,10 +154,10 @@
<input type="text" class="span3" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: smtpServer, hasfocus: smtpServerFocus" />
</div>
<div class="span1">
<div class="span2">
<span data-i18n="POPUPS_DOMAIN/LABEL_PORT"></span>
<br />
<input type="text" class="span1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
<input type="number" class="span1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: smtpPort" />
</div>
</div>