From 308be25c24138db3160bb832245e31fd0b8cdbef Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Wed, 23 Nov 2022 16:26:26 +0100 Subject: [PATCH] Resolve #695 --- .../app/libraries/snappymail/sasl/login.php | 5 ++-- test/sasl.php | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 test/sasl.php diff --git a/snappymail/v/0.0.0/app/libraries/snappymail/sasl/login.php b/snappymail/v/0.0.0/app/libraries/snappymail/sasl/login.php index 9dcbd446d..52608a49f 100644 --- a/snappymail/v/0.0.0/app/libraries/snappymail/sasl/login.php +++ b/snappymail/v/0.0.0/app/libraries/snappymail/sasl/login.php @@ -11,9 +11,8 @@ class Login extends \SnappyMail\SASL { // $challenge should be 'VXNlcm5hbWU6', but broken on some systems // See https://github.com/the-djmaze/snappymail/issues/693 - if ($challenge && \str_starts_with($this->decode($challenge), 'Username:')) { -// if ($challenge && 'Username:' !== $this->decode($challenge)) { - throw new \Exception("Invalid response: {$challenge}"); + if ($challenge && !\str_starts_with($this->decode($challenge), 'Username:')) { + throw new \Exception("Invalid response: {$this->decode($challenge)}"); } $this->passphrase = $passphrase; return $this->encode($username); diff --git a/test/sasl.php b/test/sasl.php new file mode 100644 index 000000000..f36d238e4 --- /dev/null +++ b/test/sasl.php @@ -0,0 +1,25 @@ +base64 = true; +var_dump($LOGIN->authenticate('john', 'doe', 'VXNlcm5hbWU6')); +var_dump($LOGIN->authenticate('john', 'doe', 'VXNlcm5hbWU6CG')); +var_dump($LOGIN->authenticate('john', 'doe', 'UGFzc3dvcmQ6'));