diff options
author | Thomas Schmid <schmid-thomas@gmx.net> | 2021-11-02 01:16:46 +0300 |
---|---|---|
committer | Thomas Schmid <schmid-thomas@gmx.net> | 2021-11-02 01:16:46 +0300 |
commit | 85cb013fddd0aee29476b27c589573a8394223a6 (patch) | |
tree | 4586bb3e6d09d030072a136071d2205d069769cf /src | |
parent | df816b44f07fe0dab47adbacf6af43c74fc6b85f (diff) |
Fail when server does not support a forced sasl mechanims.
Diffstat (limited to 'src')
-rw-r--r-- | src/common/libManageSieve/SieveAbstractSession.mjs | 20 | ||||
-rw-r--r-- | src/common/libManageSieve/SieveResponse.mjs | 2 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/common/libManageSieve/SieveAbstractSession.mjs b/src/common/libManageSieve/SieveAbstractSession.mjs index e3015ba8..e16a21be 100644 --- a/src/common/libManageSieve/SieveAbstractSession.mjs +++ b/src/common/libManageSieve/SieveAbstractSession.mjs @@ -214,15 +214,19 @@ class SieveAbstractSession { if (mechanism === undefined || mechanism === null) mechanism = "default"; - if (mechanism === "default") - mechanism = this.getCompatibility().getSaslMechanisms(); - else - mechanism = [mechanism]; + let mechanisms = this.getCompatibility().getSaslMechanisms(); + + if (mechanism !== "default") { + if (!mechanisms.includes(mechanism)) + throw new SieveClientException("Forced SASL Mechanism is not supported by the server (error.sasl)"); + + mechanisms = [mechanism]; + } // ... translate the SASL Mechanism into an SieveSaslLogin Object ... - while (mechanism.length > 0) { + while (mechanisms.length > 0) { // remove and test the first element... - switch (mechanism.shift().toUpperCase()) { + switch (mechanisms.shift()) { case "PLAIN": return new SieveSaslPlainRequest(); @@ -243,12 +247,12 @@ class SieveAbstractSession { // this means in case it is the only mechanism // we have no options - if (!mechanism.length) + if (!mechanisms.length) return new SieveSaslLoginRequest(); // otherwise be move it to the end of the // mechanism list. - mechanism.push("LOGIN"); + mechanisms.push("LOGIN"); break; } } diff --git a/src/common/libManageSieve/SieveResponse.mjs b/src/common/libManageSieve/SieveResponse.mjs index a627f887..87fd1d03 100644 --- a/src/common/libManageSieve/SieveResponse.mjs +++ b/src/common/libManageSieve/SieveResponse.mjs @@ -381,7 +381,7 @@ class SieveCapabilitiesResponse extends SieveSimpleResponse { this.details.implementation = value; break; case "SASL": - this.details.sasl = value.split(" "); + this.details.sasl = value.toUpperCase().split(" "); break; case "SIEVE": this.details.extensions = this.parseSieveExtensions(value); |