diff --git a/webui/Zend/Mail/Protocol/Imap.php b/webui/Zend/Mail/Protocol/Imap.php index 8d034bbd..6bb2f11c 100644 --- a/webui/Zend/Mail/Protocol/Imap.php +++ b/webui/Zend/Mail/Protocol/Imap.php @@ -92,6 +92,10 @@ class Zend_Mail_Protocol_Imap $errno = 0; $errstr = ''; + /* + * http://stackoverflow.com/questions/32211301/ssl-error-ssl3-get-server-certificatecertificate-verify-failed + */ + $contextOptions = array( 'ssl' => array( 'verify_peer' => false, diff --git a/webui/Zend/Mime/Decode.php b/webui/Zend/Mime/Decode.php index caf03e1e..8c80710a 100644 --- a/webui/Zend/Mime/Decode.php +++ b/webui/Zend/Mime/Decode.php @@ -124,43 +124,7 @@ class Zend_Mime_Decode $message, &$headers, &$body, $EOL = Zend_Mime::LINEEND ) { - // check for valid header at first line - $firstline = strtok($message, "\n"); - if (!preg_match('%^[^\s]+[^:]*:%', $firstline)) { - $headers = array(); - // TODO: we're ignoring \r for now - is this function fast enough and is it safe to asume noone needs \r? - $body = str_replace( - array( - "\r", - "\n" - ), array( - '', - $EOL - ), $message - ); - - return; - } - - // find an empty line between headers and body - // default is set new line - if (strpos($message, $EOL . $EOL)) { - list($headers, $body) = explode($EOL . $EOL, $message, 2); - // next is the standard new line - } else { - if ($EOL != "\r\n" && strpos($message, "\r\n\r\n")) { - list($headers, $body) = explode("\r\n\r\n", $message, 2); - // next is the other "standard" new line - } else { - if ($EOL != "\n" && strpos($message, "\n\n")) { - list($headers, $body) = explode("\n\n", $message, 2); - // at last resort find anything that looks like a new line - } else { - @list($headers, $body) = - @preg_split("%([\r\n]+)\\1%U", $message, 2); - } - } - } + self::splitMessageRaw($message, $headers, $body, $EOL); $headers = iconv_mime_decode_headers( $headers, ICONV_MIME_DECODE_CONTINUE_ON_ERROR @@ -273,4 +237,53 @@ class Zend_Mime_Decode { return quoted_printable_decode($string); } + + + /** + cut the original splitMessage() function to get the raw headers, SJ + */ + public static function splitMessageRaw( + $message, &$headers, &$body, $EOL = Zend_Mime::LINEEND + ) + { + // check for valid header at first line + $firstline = strtok($message, "\n"); + if (!preg_match('%^[^\s]+[^:]*:%', $firstline)) { + $headers = array(); + // TODO: we're ignoring \r for now - is this function fast enough and is it safe to asume noone needs \r? + $body = str_replace( + array( + "\r", + "\n" + ), array( + '', + $EOL + ), $message + ); + + return; + } + + // find an empty line between headers and body + // default is set new line + if (strpos($message, $EOL . $EOL)) { + list($headers, $body) = explode($EOL . $EOL, $message, 2); + // next is the standard new line + } else { + if ($EOL != "\r\n" && strpos($message, "\r\n\r\n")) { + list($headers, $body) = explode("\r\n\r\n", $message, 2); + // next is the other "standard" new line + } else { + if ($EOL != "\n" && strpos($message, "\n\n")) { + list($headers, $body) = explode("\n\n", $message, 2); + // at last resort find anything that looks like a new line + } else { + @list($headers, $body) = + @preg_split("%([\r\n]+)\\1%U", $message, 2); + } + } + } + } + + } diff --git a/webui/model/search/message.php b/webui/model/search/message.php index 3c98d9b6..77ce3142 100644 --- a/webui/model/search/message.php +++ b/webui/model/search/message.php @@ -1,5 +1,7 @@ connect_to_pilergetd(); $msg = $this->get_raw_message($id); $this->disconnect_from_pilergetd(); - $has_journal = $this->remove_journal($msg); + Zend_Mime_Decode::splitMessageRaw($msg, $headers, $body); + + $has_journal = $this->remove_journal($headers); if(Registry::get('auditor_user') == 0 && HEADER_LINE_TO_HIDE) { - $msg = preg_replace("/" . HEADER_LINE_TO_HIDE . ".{1,}(\n(\ |\t){1,}.{1,}){0,}" . "\n/i", "", $msg); + $headers = preg_replace("/" . HEADER_LINE_TO_HIDE . ".{1,}(\n(\ |\t){1,}.{1,}){0,}" . "\n/i", "", $headers); } - $pos = strpos($msg, "\n\r\n"); - if($pos == false) { - $pos = strpos($msg, "\n\n"); - } + $headers = preg_replace("/\/", ">", $headers); - if($pos == false) { return $msg; } - - $data = substr($msg, 0, $pos); - $msg = ''; - - $data = preg_replace("/\/", ">", $data); - - return array('headers' => $data, 'has_journal' => $has_journal); + return array('headers' => $headers, 'has_journal' => $has_journal); } diff --git a/webui/model/user/auth.php b/webui/model/user/auth.php index 1963565f..3218ee21 100644 --- a/webui/model/user/auth.php +++ b/webui/model/user/auth.php @@ -350,7 +350,11 @@ class ModelUserAuth extends Model { $session = Registry::get('session'); $emails = array($username); - if(!strchr($username, '@')) { return 0; } + /* + * usernames without the domain part are allowed, though + * they won't see any emails unless a post auth hook is run + * to assign some email addresses to them + */ $login = $username;