Changeset 4607 in subversion
- Timestamp:
- Mar 11, 2011 3:55:20 AM (2 years ago)
- Location:
- branches/release-0.5
- Files:
-
- 7 edited
-
CHANGELOG (modified) (1 diff)
-
SQL/postgres.initial.sql (modified) (2 diffs)
-
SQL/postgres.update.sql (modified) (1 diff)
-
index.php (modified) (2 diffs)
-
program/include/rcube_imap_generic.php (modified) (10 diffs)
-
program/include/rcube_session.php (modified) (1 diff)
-
program/lib/Net/SMTP.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-0.5/CHANGELOG
r4593 r4607 2 2 =========================== 3 3 4 - PEAR::Net_SMTP 1.5.1 5 - Force names of unique constraints in PostgreSQL DDL 6 - Add code for prevention from IMAP connection hangs when server closes socket unexpectedly 7 - Remove redundant DELETE query (for old session deletion) on login 8 - Get around unreliable rand() and mt_rand() in session ID generation (#1486281) 4 9 - Fix some emails are not shown using Cyrus IMAP (#1487820) 5 10 - Fix handling of mime-encoded words with non-integral number of octets in a word (#1487801) -
branches/release-0.5/SQL/postgres.initial.sql
r4166 r4607 26 26 "language" varchar(5), 27 27 preferences text DEFAULT ''::text NOT NULL, 28 UNIQUE (username, mail_host)28 CONSTRAINT users_username_key UNIQUE (username, mail_host) 29 29 ); 30 30 … … 218 218 headers text NOT NULL, 219 219 structure text, 220 UNIQUE (user_id, cache_key, uid)220 CONSTRAINT messages_user_id_key UNIQUE (user_id, cache_key, uid) 221 221 ); 222 222 -
branches/release-0.5/SQL/postgres.update.sql
r4469 r4607 86 86 87 87 DROP INDEX users_username_id_idx; 88 ALTER TABLE users ADD UNIQUE (username, mail_host);88 ALTER TABLE users ADD CONSTRAINT users_username_key UNIQUE (username, mail_host); 89 89 ALTER TABLE contacts ALTER email TYPE varchar(255); 90 90 -
branches/release-0.5/index.php
r4509 r4607 96 96 else if ($auth['valid'] && !$auth['abort'] && 97 97 !empty($auth['host']) && !empty($auth['user']) && 98 $RCMAIL->login($auth['user'], $auth['pass'], $auth['host'])) { 99 // create new session ID 98 $RCMAIL->login($auth['user'], $auth['pass'], $auth['host']) 99 ) { 100 // create new session ID, don't destroy the current session 101 // it was destroyed already by $RCMAIL->kill_session() above 100 102 $RCMAIL->session->remove('temp'); 101 $RCMAIL->session->regenerate_id( );103 $RCMAIL->session->regenerate_id(false); 102 104 103 105 // send auth cookie if necessary … … 111 113 if ($url = get_input_value('_url', RCUBE_INPUT_POST)) { 112 114 parse_str($url, $query); 113 115 114 116 // prevent endless looping on login page 115 117 if ($query['_task'] == 'login') -
branches/release-0.5/program/include/rcube_imap_generic.php
r4593 r4607 214 214 $line = ''; 215 215 216 if (!$this->fp) {217 return NULL;218 }219 220 216 if (!$size) { 221 217 $size = 1024; … … 223 219 224 220 do { 225 if ( feof($this->fp)) {221 if ($this->eof()) { 226 222 return $line ? $line : NULL; 227 223 } … … 230 226 231 227 if ($buffer === false) { 232 @fclose($this->fp); 233 $this->fp = null; 228 $this->closeSocket(); 234 229 break; 235 230 } … … 238 233 } 239 234 $line .= $buffer; 240 } while ( $buffer[strlen($buffer)-1]!= "\n");235 } while (substr($buffer, -1) != "\n"); 241 236 242 237 return $line; … … 268 263 $data = ''; 269 264 $len = 0; 270 while ($len < $bytes && ! feof($this->fp))265 while ($len < $bytes && !$this->eof()) 271 266 { 272 267 $d = fread($this->fp, $bytes-$len); … … 313 308 $this->errornum = self::ERROR_BAD; 314 309 } else if ($res == 'BYE') { 315 @fclose($this->fp); 316 $this->fp = null; 310 $this->closeSocket(); 317 311 $this->errornum = self::ERROR_BYE; 318 312 } … … 340 334 } 341 335 336 private function eof() 337 { 338 if (!is_resource($this->fp)) { 339 return true; 340 } 341 342 // If a connection opened by fsockopen() wasn't closed 343 // by the server, feof() will hang. 344 $start = microtime(true); 345 346 if (feof($this->fp) || 347 ($this->prefs['timeout'] && (microtime(true) - $start > $this->prefs['timeout'])) 348 ) { 349 $this->closeSocket(); 350 return true; 351 } 352 353 return false; 354 } 355 356 private function closeSocket() 357 { 358 @fclose($this->fp); 359 $this->fp = null; 360 } 361 342 362 function setError($code, $msg='') 343 363 { … … 361 381 if ($error && preg_match('/^\* (BYE|BAD) /i', $string, $m)) { 362 382 if (strtoupper($m[1]) == 'BYE') { 363 @fclose($this->fp); 364 $this->fp = null; 383 $this->closeSocket(); 365 384 } 366 385 return true; … … 702 721 } 703 722 723 if ($this->prefs['timeout'] <= 0) { 724 $this->prefs['timeout'] = ini_get('default_socket_timeout'); 725 } 726 704 727 // Connect 705 if ($this->prefs['timeout'] > 0) 706 $this->fp = @fsockopen($host, $this->prefs['port'], $errno, $errstr, $this->prefs['timeout']); 707 else 708 $this->fp = @fsockopen($host, $this->prefs['port'], $errno, $errstr); 728 $this->fp = @fsockopen($host, $this->prefs['port'], $errno, $errstr, $this->prefs['timeout']); 709 729 710 730 if (!$this->fp) { … … 856 876 } 857 877 858 @fclose($this->fp); 859 $this->fp = false; 878 $this->closeSocket(); 860 879 } 861 880 -
branches/release-0.5/program/include/rcube_session.php
r4509 r4607 184 184 185 185 186 public function regenerate_id() 187 { 188 $randval = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; 189 190 for ($random = '', $i=1; $i <= 32; $i++) { 191 $random .= substr($randval, mt_rand(0,(strlen($randval) - 1)), 1); 192 } 193 194 // use md5 value for id or remove capitals from string $randval 195 $random = md5($random); 196 197 // delete old session record 198 $this->destroy(session_id()); 199 200 session_id($random); 201 202 $cookie = session_get_cookie_params(); 203 $lifetime = $cookie['lifetime'] ? time() + $cookie['lifetime'] : 0; 204 205 rcmail::setcookie(session_name(), $random, $lifetime); 206 186 public function regenerate_id($destroy=true) 187 { 188 session_regenerate_id($destroy); 189 190 $this->vars = false; 191 $this->key = session_id(); 207 192 return true; 208 193 } -
branches/release-0.5/program/lib/Net/SMTP.php
r4073 r4607 107 107 108 108 /** 109 * The socket I/O timeout value in seconds. 110 * @var int 111 * @access private 112 */ 113 var $_timeout = 0; 114 115 /** 109 116 * The most recent server response code. 110 117 * @var int … … 149 156 * @param string $localhost The value to give when sending EHLO or HELO. 150 157 * @param boolean $pipeling Use SMTP command pipelining 158 * @param integer $timeout Socket I/O timeout in seconds. 151 159 * 152 160 * @access public 153 161 * @since 1.0 154 162 */ 155 function Net_SMTP($host = null, $port = null, $localhost = null, $pipelining = false) 163 function Net_SMTP($host = null, $port = null, $localhost = null, 164 $pipelining = false, $timeout = 0) 156 165 { 157 166 if (isset($host)) { … … 167 176 168 177 $this->_socket = new Net_Socket(); 178 $this->_timeout = $timeout; 169 179 170 180 /* Include the Auth_SASL package. If the package is not … … 180 190 181 191 /** 192 * Set the socket I/O timeout value in seconds plus microseconds. 193 * 194 * @param integer $seconds Timeout value in seconds. 195 * @param integer $microseconds Additional value in microseconds. 196 * 197 * @access public 198 * @since 1.5.0 199 */ 200 function setTimeout($seconds, $microseconds = 0) { 201 return $this->_socket->setTimeout($seconds, $microseconds); 202 } 203 204 /** 182 205 * Set the value of the debugging flag. 183 206 * … … 370 393 * 371 394 * @param int $timeout The timeout value (in seconds) for the 372 * socket connection .395 * socket connection attempt. 373 396 * @param bool $persistent Should a persistent socket connection 374 397 * be used? … … 387 410 return PEAR::raiseError('Failed to connect socket: ' . 388 411 $result->getMessage()); 412 } 413 414 /* 415 * Now that we're connected, reset the socket's timeout value for 416 * future I/O operations. This allows us to have different socket 417 * timeout values for the initial connection (our $timeout parameter) 418 * and all other socket operations. 419 */ 420 if (PEAR::isError($error = $this->setTimeout($this->_timeout))) { 421 return $error; 389 422 } 390 423 … … 618 651 $digest = &Auth_SASL::factory('digestmd5'); 619 652 $auth_str = base64_encode($digest->getResponse($uid, $pwd, $challenge, 620 $this->host, "smtp", $authz)); 653 $this->host, "smtp", 654 $authz)); 621 655 622 656 if (PEAR::isError($error = $this->_put($auth_str))) { … … 831 865 $args .= ' XVERP=' . $params['verp']; 832 866 } 833 } elseif (is_string($params) ) {867 } elseif (is_string($params) && !empty($params)) { 834 868 $args .= ' ' . $params; 835 869 } … … 920 954 } 921 955 922 /* RFC 1870, section 3, subsection 3 states "a value of zero 923 * indicates that no fixed maximum message size is in force". 924 * Furthermore, it says that if "the parameter is omitted no 925 * information is conveyed about the server's fixed maximum 926 * message size". */ 927 if (isset($this->_esmtp['SIZE']) && ($this->_esmtp['SIZE'] > 0)) { 928 /* Start by considering the size of the optional headers string. 929 * We also account for the addition 4 character "\r\n\r\n" 930 * separator sequence. */ 931 $size = (is_null($headers)) ? 0 : strlen($headers) + 4; 932 933 if (is_resource($data)) { 934 $stat = fstat($data); 935 if ($stat === false) { 936 return PEAR::raiseError('Failed to get file size'); 937 } 938 $size += $stat['size']; 939 } else { 940 $size += strlen($data); 941 } 942 943 if ($size >= $this->_esmtp['SIZE']) { 944 $this->disconnect(); 945 return PEAR::raiseError('Message size exceeds server limit'); 946 } 956 /* Start by considering the size of the optional headers string. We 957 * also account for the addition 4 character "\r\n\r\n" separator 958 * sequence. */ 959 $size = (is_null($headers)) ? 0 : strlen($headers) + 4; 960 961 if (is_resource($data)) { 962 $stat = fstat($data); 963 if ($stat === false) { 964 return PEAR::raiseError('Failed to get file size'); 965 } 966 $size += $stat['size']; 967 } else { 968 $size += strlen($data); 969 } 970 971 /* RFC 1870, section 3, subsection 3 states "a value of zero indicates 972 * that no fixed maximum message size is in force". Furthermore, it 973 * says that if "the parameter is omitted no information is conveyed 974 * about the server's fixed maximum message size". */ 975 $limit = (isset($this->_esmtp['SIZE'])) ? $this->_esmtp['SIZE'] : 0; 976 if ($limit > 0 && $size >= $limit) { 977 $this->disconnect(); 978 return PEAR::raiseError('Message size exceeds server limit'); 947 979 } 948 980 … … 975 1007 } 976 1008 } else { 977 if (!isset($size))978 $size = strlen($data);979 1009 /* 980 1010 * Break up the data by sending one chunk (up to 512k) at a time.
Note: See TracChangeset
for help on using the changeset viewer.
