* messages, set the maximum size of the displayed message here (in
* bytes). If exceeded, the user will only be able to download the part.
* Set to 0 to disable this check. */
- 'limit_inline_size' => 1048576
+ 'limit_inline_size' => 1048576,
+ /* If you want to scan ALL incoming text/plain messages for UUencoded
+ * data, set the following to true. This is very performance intensive and
+ * can take a long time for large messages. It is not recommended (as
+ * UUencoded data is very rare anymore) and is disabled by default. */
+ 'uudecode' => false
);
/**
*/
public function embeddedMimeParts()
{
- return !empty($GLOBALS['conf']['utils']['gnupg']) && $GLOBALS['prefs']->getValue('pgp_scan_body');
+ return (!empty($GLOBALS['conf']['utils']['gnupg']) && $GLOBALS['prefs']->getValue('pgp_scan_body')) || $this->getConfigParam('uudecode');
}
/**
*/
public function getEmbeddedMimeParts()
{
+ $ret = null;
+
+ if (!empty($GLOBALS['conf']['utils']['gnupg']) &&
+ $GLOBALS['prefs']->getValue('pgp_scan_body')) {
+ $ret = $this->_parsePGP();
+ }
+
+ if (is_null($ret) && $this->getConfigParam('uudecode')) {
+ $ret = $this->_parseUUencode();
+ }
+
+ return $ret;
+ }
+
+ /*
+ */
+ protected function _parsePGP()
+ {
/* Avoid infinite loop. */
$imp_pgp = &Horde_Crypt::singleton(array('imp', 'pgp'));
$parts = $imp_pgp->parsePGPData($this->_mimepart->getContents());
return array($mime_id => $new_part);
}
+
+ protected function _parseUUencode()
+ {
+ $text = String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset());
+
+ /* Don't want to use convert_uudecode() here as there may be multiple
+ * files residing in the text. */
+ require_once 'Mail/mimeDecode.php';
+ $files = &Mail_mimeDecode::uudecode($text);
+ if (empty($files)) {
+ return null;
+ }
+
+ $new_part = is_a($this->_mimepart, 'Horde_Mime_Message')
+ ? new Horde_Mime_Message()
+ : new Horde_Mime_Part();
+ $new_part->setType('multipart/mixed');
+ $mime_id = $this->_mimepart->getMimeId();
+
+ $text_part = new Horde_Mime_Part();
+ $text_part->setType('text/plain');
+ $text_part->setCharset(NLS::getCharset());
+ $text_part->setContents(preg_replace("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", "\n", $text));
+ $new_part->addPart($text_part);
+
+ reset($files);
+ while (list(,$file) = each($files)) {
+ $uupart = new Horde_Mime_Part();
+ $uupart->setType('application/octet-stream');
+ $uupart->setContents($file['filedata']);
+ $uupart->setName(strip_tags($file['filename']));
+ $new_part->addPart($uupart);
+ }
+
+ $new_part->buildMimeIds(is_a($new_part, 'Horde_Mime_Message') ? null : $mime_id);
+
+ return array($mime_id => $new_part);
+ }
}