Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Replace Pear dependency to Mail_mimeDecode to Composer library. Shoul…
Browse files Browse the repository at this point in the history
…d remove problematic plugin dependency, see #1385
  • Loading branch information
cdujeu committed Oct 5, 2017
1 parent 4db700f commit a246374
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
3 changes: 2 additions & 1 deletion core/src/core/composer.json
Expand Up @@ -20,7 +20,8 @@
"aws/aws-sdk-php": "^3.19.4",
"meenie/javascript-packer":"1.1",
"dapphp/securimage":"3.6.4",
"phpseclib/phpseclib":"2.0.3"
"phpseclib/phpseclib":"2.0.3",
"pear/mail_mime-decode":"1.5.5.2"
}

}
26 changes: 8 additions & 18 deletions core/src/plugins/editor.eml/EmlParser.php
Expand Up @@ -40,6 +40,8 @@
use Pydio\Core\Utils\TextEncoder;
use Pydio\Core\Utils\Vars\UrlUtils;

use Mail_mimeDecode;

defined('AJXP_EXEC') or die( 'Access not allowed');

/**
Expand All @@ -50,13 +52,6 @@ class EmlParser extends Plugin
{
public static $currentListingOnlyEmails;

public function performChecks()
{
if (!ApplicationState::searchIncludePath("Mail/mimeDecode.php")) {
throw new \Exception("Cannot find Mail/mimeDecode PEAR library");
}
}

/**
* @param \Psr\Http\Message\ServerRequestInterface $requestInterface
* @param \Psr\Http\Message\ResponseInterface $responseInterface
Expand Down Expand Up @@ -117,7 +112,6 @@ public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestIn
$x->addChunk($doc);
break;
case "eml_get_bodies":
require_once("Mail/mimeDecode.php");
$params = array(
'include_bodies' => true,
'decode_bodies' => true,
Expand All @@ -130,7 +124,7 @@ public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestIn
$content = file_get_contents($file);
}

$decoder = new \Mail_mimeDecode($content);
$decoder = new Mail_mimeDecode($content);
$structure = $decoder->decode($params);
$html = $this->_findPartByCType($structure, "text", "html");
$text = $this->_findPartByCType($structure, "text", "plain");
Expand All @@ -148,7 +142,6 @@ public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestIn
$attachId = $httpVars["attachment_id"];
if(!isset($attachId)) break;

require_once("Mail/mimeDecode.php");
$params = array(
'include_bodies' => true,
'decode_bodies' => true,
Expand All @@ -160,7 +153,7 @@ public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestIn
} else {
$content = file_get_contents($file);
}
$decoder = new \Mail_mimeDecode($content);
$decoder = new Mail_mimeDecode($content);
$structure = $decoder->decode($params);
$part = $this->_findAttachmentById($structure, $attachId);

Expand All @@ -178,7 +171,6 @@ public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestIn
throw new \Pydio\Core\Exception\PydioException("Wrong Parameters");
}

require_once("Mail/mimeDecode.php");
$params = array(
'include_bodies' => true,
'decode_bodies' => true,
Expand All @@ -191,7 +183,7 @@ public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestIn
$content = file_get_contents($file);
}

$decoder = new \Mail_mimeDecode($content);
$decoder = new Mail_mimeDecode($content);
$structure = $decoder->decode($params);
$part = $this->_findAttachmentById($structure, $attachId);
if ($part !== false) {
Expand Down Expand Up @@ -289,14 +281,13 @@ protected function wrapperIsImap($node){
public function mimeExtractorCallback($masterFile, $targetFile)
{
$metadata = array();
require_once("Mail/mimeDecode.php");
$params = array(
'include_bodies' => true,
'decode_bodies' => false,
'decode_headers' => 'UTF-8'
);
$content = file_get_contents($masterFile);
$decoder = new \Mail_mimeDecode($content);
$decoder = new Mail_mimeDecode($content);
$structure = $decoder->decode($params);
$allowedHeaders = array("to", "from", "subject", "message-id", "mime-version", "date", "return-path");
foreach ($structure->headers as $hKey => $hValue) {
Expand Down Expand Up @@ -397,18 +388,17 @@ public function lsPostProcess(\Psr\Http\Message\ServerRequestInterface $requestI
* Enter description here ...
* @param string $file url
* @param boolean $cacheRemoteContent
* @return \Mail_mimeDecode
* @return Mail_mimeDecode
*/
public function getStructureDecoder($file, $cacheRemoteContent = false)
{
require_once ("Mail/mimeDecode.php");
if ($cacheRemoteContent) {
$cache = LocalCache::getItem ( "eml_remote", $file , null, array($this, "computeCacheId"));
$content = $cache->getData ();
} else {
$content = file_get_contents ( $file );
}
$decoder = new \Mail_mimeDecode ( $content );
$decoder = new Mail_mimeDecode ( $content );

header ( 'Content-Type: text/xml; charset=UTF-8' );
header ( 'Cache-Control: no-cache' );
Expand Down

0 comments on commit a246374

Please sign in to comment.