From e4e38e02cfe626ffeda26b1d4a08df7a6cd3997d Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Wed, 02 Feb 2011 14:41:41 -0500
Subject: [PATCH] Fix inconsistency in de_DE localization (#1487749)
---
program/include/rcube_imap_generic.php | 85 +++++++++++++++++++++++++-----------------
1 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index 9eeb028..e8b1fd4 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -5,7 +5,7 @@
| program/include/rcube_imap_generic.php |
| |
| This file is part of the Roundcube Webmail client |
- | Copyright (C) 2005-2010, Roundcube Dev. - Switzerland |
+ | Copyright (C) 2005-2010, The Roundcube Dev Team |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
@@ -371,10 +371,43 @@
return false;
}
- function getCapability($name)
+ private function hasCapability($name)
{
+ if (empty($this->capability) || $name == '') {
+ return false;
+ }
+
if (in_array($name, $this->capability)) {
return true;
+ }
+ else if (strpos($name, '=')) {
+ return false;
+ }
+
+ $result = array();
+ foreach ($this->capability as $cap) {
+ $entry = explode('=', $cap);
+ if ($entry[0] == $name) {
+ $result[] = $entry[1];
+ }
+ }
+
+ return !empty($result) ? $result : false;
+ }
+
+ /**
+ * Capabilities checker
+ *
+ * @param string $name Capability name
+ *
+ * @return mixed Capability values array for key=value pairs, true/false for others
+ */
+ function getCapability($name)
+ {
+ $result = $this->hasCapability($name);
+
+ if (!empty($result)) {
+ return $result;
}
else if ($this->capability_readed) {
return false;
@@ -390,11 +423,7 @@
$this->capability_readed = true;
- if (in_array($name, $this->capability)) {
- return true;
- }
-
- return false;
+ return $this->hasCapability($name);
}
function clearCapability()
@@ -735,17 +764,17 @@
// check for supported auth methods
if ($auth_method == 'CHECK') {
- if ($this->getCapability('AUTH=DIGEST-MD5')) {
- $auth_methods[] = 'DIGEST-MD5';
- }
- if ($this->getCapability('AUTH=CRAM-MD5') || $this->getCapability('AUTH=CRAM_MD5')) {
- $auth_methods[] = 'CRAM-MD5';
- }
- if ($this->getCapability('AUTH=PLAIN')) {
- $auth_methods[] = 'PLAIN';
+ if ($auth_caps = $this->getCapability('AUTH')) {
+ $auth_methods = $auth_caps;
}
// RFC 2595 (LOGINDISABLED) LOGIN disabled when connection is not secure
- if (!$this->getCapability('LOGINDISABLED')) {
+ $login_disabled = $this->getCapability('LOGINDISABLED');
+ if (($key = array_search('LOGIN', $auth_methods)) !== false) {
+ if ($login_disabled) {
+ unset($auth_methods[$key]);
+ }
+ }
+ else if (!$login_disabled) {
$auth_methods[] = 'LOGIN';
}
}
@@ -766,8 +795,10 @@
// Authenticate
foreach ($auth_methods as $method) {
switch ($method) {
- case 'DIGEST-MD5':
+ case 'CRAM_MD5':
+ $method = 'CRAM-MD5';
case 'CRAM-MD5':
+ case 'DIGEST-MD5':
case 'PLAIN':
$result = $this->authenticate($user, $password, $method);
break;
@@ -1463,7 +1494,7 @@
// INTERNALDATE "16-Nov-2008 21:08:46 +0100" BODYSTRUCTURE (...)
// BODY[HEADER.FIELDS ...
- if (preg_match('/^\* [0-9]+ FETCH \((.*) BODY/s', $line, $matches)) {
+ if (preg_match('/^\* [0-9]+ FETCH \((.*) BODY/sU', $line, $matches)) {
$str = $matches[1];
// swap parents with quotes, then explode
@@ -1500,7 +1531,7 @@
// BODYSTRUCTURE
if ($bodystr) {
- while (!preg_match('/ BODYSTRUCTURE (.*) BODY\[HEADER.FIELDS/s', $line, $m)) {
+ while (!preg_match('/ BODYSTRUCTURE (.*) BODY\[HEADER.FIELDS/sU', $line, $m)) {
$line2 = $this->readLine(1024);
$line .= $this->multLine($line2, true);
}
@@ -3192,21 +3223,7 @@
*/
private function strToTime($date)
{
- // support non-standard "GMTXXXX" literal
- $date = preg_replace('/GMT\s*([+-][0-9]+)/', '\\1', $date);
- // if date parsing fails, we have a date in non-rfc format.
- // remove token from the end and try again
- while ((($ts = @strtotime($date))===false) || ($ts < 0)) {
- $d = explode(' ', $date);
- array_pop($d);
- if (!$d) {
- break;
- }
- $date = implode(' ', $d);
- }
-
- $ts = (int) $ts;
-
+ $ts = (int) rcube_strtotime($date);
return $ts < 0 ? 0 : $ts;
}
--
Gitblit v1.9.1