From 4757608097aec3c8c4c8bfa2b892ea603f583547 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Tue, 26 Oct 2010 04:43:23 -0400
Subject: [PATCH] - Improve pre-auth and auth capabilities handling
---
program/include/rcube_imap_generic.php | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index 82018c9..c79124b 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -512,7 +512,7 @@
if ($result == self::ERROR_OK) {
// optional CAPABILITY response
if ($line && preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches)) {
- $this->parseCapability($matches[1]);
+ $this->parseCapability($matches[1], true);
}
return $this->fp;
}
@@ -538,7 +538,7 @@
// re-set capabilities list if untagged CAPABILITY response provided
if (preg_match('/\* CAPABILITY (.+)/i', $response, $matches)) {
- $this->parseCapability($matches[1]);
+ $this->parseCapability($matches[1], true);
}
if ($code == self::ERROR_OK) {
@@ -746,8 +746,7 @@
// RFC3501 [7.1] optional CAPABILITY response
if (preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches)) {
- $this->parseCapability($matches[1]);
- $this->capability_readed = true;
+ $this->parseCapability($matches[1], true);
}
$this->message .= $line;
@@ -795,6 +794,9 @@
$auth_methods[] = $auth_method == 'AUTH' ? 'CRAM-MD5' : $auth_method;
}
+ // pre-login capabilities can be not complete
+ $this->capability_readed = false;
+
// Authenticate
foreach ($auth_methods as $method) {
switch ($method) {
@@ -818,11 +820,7 @@
// Connected and authenticated
if (is_resource($result)) {
if ($this->prefs['force_caps']) {
- // forget current capabilities
$this->clearCapability();
- } else {
- // pre-login capabilities can be not complete
- $this->capability_readed = false;
}
$this->getRootDir();
$this->logged = true;
@@ -2858,7 +2856,7 @@
if (($options & self::COMMAND_CAPABILITY) && $code == self::ERROR_OK
&& preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches)
) {
- $this->parseCapability($matches[1]);
+ $this->parseCapability($matches[1], true);
}
return $noresp ? $code : array($code, $response);
@@ -2999,7 +2997,7 @@
return $string;
}
- private function parseCapability($str)
+ private function parseCapability($str, $trusted=false)
{
$str = preg_replace('/^\* CAPABILITY /i', '', $str);
@@ -3008,6 +3006,10 @@
if (!isset($this->prefs['literal+']) && in_array('LITERAL+', $this->capability)) {
$this->prefs['literal+'] = true;
}
+
+ if ($trusted) {
+ $this->capability_readed = true;
+ }
}
/**
--
Gitblit v1.9.1