alecpl
2010-10-26 4757608097aec3c8c4c8bfa2b892ea603f583547
- Improve pre-auth and auth capabilities handling


1 files modified
22 ■■■■ changed files
program/include/rcube_imap_generic.php 22 ●●●● patch | view | raw | blame | history
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;
        }
    }
    /**