Commit 96826724 authored by jonnybradley's avatar jonnybradley

[FIX] mailin: Various fixes, Zend changed header access for content-type etc,...

[FIX] mailin: Various fixes, Zend changed header access for content-type etc, truncate page names to 160 chars and message-id may not be present
parent 8051a3df
Pipeline #50038725 failed with stages
in 27 minutes and 22 seconds
......@@ -90,11 +90,17 @@ class WikiPut implements ActionInterface
function execute(Account $account, Message $message)
{
$tikilib = TikiLib::lib('tiki');
$wikilib = TikiLib::lib('wiki');
$user = $message->getAssociatedUser();
$page = $this->getPage($message, true);
if (strlen($page) > 160) {
$smarty = TikiLib::lib('smarty');
$smarty->loadPlugin('smarty_modifier_truncate');
$page = smarty_modifier_truncate($page, 159, '...', false, true);
}
if ($this->canAttach($account, $message) && $account->hasAutoAttach()) {
foreach ($message->getAttachments() as $att) {
$link = $this->attachFile($page, $att, $user);
......@@ -102,10 +108,12 @@ class WikiPut implements ActionInterface
}
}
if ($this->canAttach($account, $message) && $account->hasInlineAttach() && $body = $message->getHtmlBody(false)) {
$body = $message->getHtmlBody( false);
if ($this->canAttach($account, $message) && $account->hasInlineAttach() && $body) {
$body = $this->handleInlineImages($page, $body, $message);
} else {
$body = $message->getHtmlBody(false);
$body = $message->getHtmlBody();
}
$data = $account->parseBody($body);
......@@ -138,12 +146,12 @@ class WikiPut implements ActionInterface
$structlib = TikiLib::lib('struct');
$structlib->s_create_page($parent_id, $after_ref_id, $page, $alias, $structure_id, $options);
$content .= "Page: $page has been added to structureId: " . $structure_id . "<br />";
$comment = "Page: $page has been added to structureId: $structure_id by " . $account->getAddress();
$tikilib->update_page(
$page,
$body,
"Updated from " . $account->getAddress(),
$comment,
$user,
$options['ip_source'],
'', //desc
......
......@@ -53,7 +53,9 @@ class Pop3 implements SourceInterface
$toDelete[] = $i;
});
$from = $source->from ?: $source->{'return-path'};
$message->setMessageId(str_replace(['<', '>'], '', $source->{'message-id'}));
if (! empty($source->{'message-id'})) {
$message->setMessageId(str_replace(['<', '>'], '', $source->{'message-id'}));
}
$message->setRawFrom($from);
$message->setSubject($source->subject);
$message->setRecipient($source->to);
......@@ -103,7 +105,8 @@ class Pop3 implements SourceInterface
*/
private function getBody($part, $type)
{
if (! $part->isMultipart() && 0 === strpos($part->getHeaders()->get('Content-Type'), $type)) {
$contentType = $part->getHeaders()->get('Content-Type');
if (! $part->isMultipart() && (! $contentType || 0 === strpos($contentType->getFieldValue(), $type))) {
return $this->decode($part);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment