mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-24 13:40:29 +01:00
Ticket system improvements for import encoding, ticket system limited display of html elements (strip_tags)
This commit is contained in:
parent
1fdd6dbf95
commit
613d45b1cc
@ -62,9 +62,11 @@ class MailAttachmentData implements MailAttachmentInterface
|
||||
{
|
||||
$encodingHeader = $part->getHeader('content-transfer-encoding');
|
||||
if ($encodingHeader === null) {
|
||||
throw new InvalidArgumentException('missing header: "Content-Transfer-Encoding"');
|
||||
// Assume this is no error (?) throw new InvalidArgumentException('missing header: "Content-Transfer-Encoding"');
|
||||
$encoding = '';
|
||||
} else {
|
||||
$encoding = $encodingHeader->getValue();
|
||||
}
|
||||
$encoding = $encodingHeader->getValue();
|
||||
$dispositionHeader = $part->getHeader('content-disposition');
|
||||
if ($dispositionHeader === null) {
|
||||
throw new InvalidArgumentException('missing header: "Content-Disposition"');
|
||||
@ -111,9 +113,27 @@ class MailAttachmentData implements MailAttachmentInterface
|
||||
else if ($disposition == 'inline') {
|
||||
$isInline = true;
|
||||
$filename = ""; // This is questionable
|
||||
} else {
|
||||
}
|
||||
else if (strpos($disposition,'attachment;\n') == 0) { // No filename, check for content type message/rfc822
|
||||
|
||||
$contenttypeHeader = $part->getHeader('content-type');
|
||||
if ($contenttypeHeader === null) {
|
||||
throw new InvalidArgumentException('missing header: "Content-Type"');
|
||||
}
|
||||
$contenttype = $contenttypeHeader->getValue();
|
||||
|
||||
if ($contenttype == 'message/rfc822') {
|
||||
$isInline = false;
|
||||
$filename = 'ForwardedMessage.eml';
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('unexpected header value "Content-Disposition" = "%s"', $disposition)
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('unexpected header value "Content-Disposition" = "%s"', $disposition)
|
||||
sprintf('unexpected header value "Content-Disposition" = "%s", not message/rfc822', $disposition)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,22 @@ class TicketFormatter
|
||||
*/
|
||||
public function encodeToUtf8(string $string): string
|
||||
{
|
||||
$encoding = mb_detect_encoding($string, 'UTF-8, ISO-8859-1, ISO-8859-15', true);
|
||||
|
||||
return mb_convert_encoding(
|
||||
$converted = mb_convert_encoding(
|
||||
$string,
|
||||
'UTF-8',
|
||||
$encoding
|
||||
'auto'
|
||||
);
|
||||
|
||||
// Fallback
|
||||
if ($converted === false) {
|
||||
$converted = mb_convert_encoding(
|
||||
$string,
|
||||
'UTF-8',
|
||||
'iso-8859-1'
|
||||
);
|
||||
}
|
||||
|
||||
return ($converted);
|
||||
}
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ class TicketImportHelper
|
||||
}
|
||||
try {
|
||||
|
||||
$this->logger->debug('Start import', ['message' => $message->getSubject()]);
|
||||
$this->logger->debug('Start import', ['message' => $message]);
|
||||
|
||||
$result = $this->importMessage($message);
|
||||
|
||||
@ -545,13 +545,28 @@ class TicketImportHelper
|
||||
$htmlBody = $message->getHtmlBody();
|
||||
if ($htmlBody === null) {
|
||||
$htmlBody = '';
|
||||
}
|
||||
|
||||
if ($plainTextBody == '' && $htmlBody == '') {
|
||||
$simple_content = $message->getContent();
|
||||
if (empty($simple_content)) {
|
||||
$this->logger->debug('Empty mail',['message' => $message]);
|
||||
} else {
|
||||
$plainTextBody = $simple_content;
|
||||
$htmlBody = nl2br(htmlentities($simple_content));
|
||||
}
|
||||
}
|
||||
|
||||
$this->logger->debug('Text',['plain' => $plainTextBody, 'html' => $htmlBody, 'simple_content' => $simple_content]);
|
||||
|
||||
$action = $this->formatter->encodeToUtf8($plainTextBody);
|
||||
$action_html = $this->formatter->encodeToUtf8($htmlBody);
|
||||
if (strlen($action_html) < strlen($action)) {
|
||||
$action_html = nl2br($action);
|
||||
}
|
||||
|
||||
$this->logger->debug('Text (converted)',['plain' => $action, 'html' => $action_html]);
|
||||
|
||||
// Import database emailbackup
|
||||
$date = $message->getDate();
|
||||
if (is_null($date)) { // This should not be happening -> Todo check getDate function
|
||||
@ -576,7 +591,7 @@ class TicketImportHelper
|
||||
|
||||
if ($result == 0) {
|
||||
|
||||
$this->logger->debug('Importing message',['']);
|
||||
$this->logger->debug('Importing message',['message' => $message]);
|
||||
|
||||
$attachments = $message->getAttachments();
|
||||
$anhang = count($attachments) > 0 ? 1 : 0;
|
||||
|
@ -351,7 +351,7 @@ class Ticket {
|
||||
$this->app->Tpl->Set("NACHRICHT_RECIPIENTS",htmlentities($message['quelle']));
|
||||
}
|
||||
$this->app->Tpl->Set("NACHRICHT_CC_RECIPIENTS",htmlentities($message['mail_cc_recipients']));
|
||||
$this->app->Tpl->Set("NACHRICHT_BETREFF",'<a href="index.php?module=ticket&action=text&mid='.$message['id'].'" target="_blank">'.htmlentities($message['betreff']).'</a>');
|
||||
$this->app->Tpl->Set("NACHRICHT_BETREFF",'<a href="index.php?module=ticket&action=text&mid='.$message['id'].'&insecure=1" target="_blank">'.htmlentities($message['betreff']).'</a>');
|
||||
$this->app->Tpl->Set("NACHRICHT_FLOAT","left");
|
||||
$this->app->Tpl->Set("META_FLOAT","right");
|
||||
$this->app->Tpl->Set("NACHRICHT_ZEIT",$message['zeit']);
|
||||
@ -368,9 +368,21 @@ class Ticket {
|
||||
}
|
||||
}
|
||||
|
||||
function ticket_text() {
|
||||
|
||||
$secure_html_tags = array(
|
||||
'<br>',
|
||||
'<p>',
|
||||
'<strong>',
|
||||
'<b>',
|
||||
'<table>',
|
||||
'<tr>',
|
||||
'<td>',
|
||||
'<style>'
|
||||
);
|
||||
|
||||
function ticket_text() {
|
||||
$mid = $this->app->Secure->GetGET('mid');
|
||||
$insecure = $this->app->Secure->GetGET('insecure');
|
||||
|
||||
if (empty($mid)) {
|
||||
return;
|
||||
@ -381,7 +393,18 @@ class Ticket {
|
||||
if (empty($messages)) {
|
||||
}
|
||||
|
||||
$this->app->Tpl->Set("TEXT",$messages[0]['text']);
|
||||
if ($insecure) {
|
||||
$this->app->Tpl->Set("TEXT",$messages[0]['text']);
|
||||
} else {
|
||||
|
||||
$secure_text = strip_tags($messages[0]['text'],$secure_html_tags);
|
||||
|
||||
if (strlen($secure_text) != strlen($messages[0]['text'])) {
|
||||
// $secure_text = "<p style=\"all: initial;border-bottom-color:black;border-bottom-style:solid;border-bottom-width:1px;display:block;font-size:small;\">Einige Elemente wurden durch OpenXE blockiert.</p>".$secure_text;
|
||||
$secure_text = "<img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/icon-invisible.svg\" alt=\"Einige Elemente wurden durch OpenXE blockiert.\" title=\"Einige Elemente wurden durch OpenXE blockiert.\" border=\"0\" style=\"all: initial;display:block;float:right;font-size:small;\">".$secure_text;
|
||||
}
|
||||
$this->app->Tpl->Set("TEXT",$secure_text);
|
||||
}
|
||||
$this->app->Tpl->Output('ticket_text.tpl');
|
||||
$this->app->ExitXentral();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user