gui fixes

Change-Id: I5592a96f486f64404f044b2199e74284fd2e46fd
Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
SJ 2016-09-15 22:08:04 +02:00
parent 338571d299
commit 91fbeebc0f
4 changed files with 69 additions and 54 deletions

View File

@ -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,

View File

@ -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);
}
}
}
}
}

View File

@ -1,5 +1,7 @@
<?php
require 'Zend/Mime/Decode.php';
class ModelSearchMessage extends Model {
public $encoding_aliases = array(
@ -192,32 +194,24 @@ class ModelSearchMessage extends Model {
public function get_message_headers($id = '') {
$data = '';
$headers = '';
$this->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("/\</", "&lt;", $headers);
$headers = preg_replace("/\>/", "&gt;", $headers);
if($pos == false) { return $msg; }
$data = substr($msg, 0, $pos);
$msg = '';
$data = preg_replace("/\</", "&lt;", $data);
$data = preg_replace("/\>/", "&gt;", $data);
return array('headers' => $data, 'has_journal' => $has_journal);
return array('headers' => $headers, 'has_journal' => $has_journal);
}

View File

@ -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;