X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=banana%2Fmimepart.inc.php;h=6b0f3994a2c5b2f8f1d7f69d598a88ffac7b7f2b;hb=ee4eff664008010cc1910cc543f15719a27de6c3;hp=ef549c695324bbe2d9ea2b8ff16a071689dd54ca;hpb=18285f74dcefef7beaf664a4ac1f7cf51fa0ea07;p=banana.git diff --git a/banana/mimepart.inc.php b/banana/mimepart.inc.php index ef549c6..6b0f399 100644 --- a/banana/mimepart.inc.php +++ b/banana/mimepart.inc.php @@ -179,7 +179,7 @@ class BananaMimePart if (empty($filename)) { $filename = $this->getHeader('content-type', '/name="?([^"]+)"?/'); } - } + } list($type, $subtype) = explode('/', $content_type); switch ($type) { case 'text': case 'message': @@ -221,7 +221,7 @@ class BananaMimePart $newpart = new BananaMimePart($part); if (!is_null($newpart->content_type)) { if ($signed && $newpart->content_type == $this->signature['protocole']) { - $signature = $newpart->body; + $signature = $newpart->body; } elseif ($signed) { $signed_message = $part; } @@ -337,7 +337,7 @@ class BananaMimePart } if (!is_null($this->charset)) { - $body = iconv($this->charset, 'UTF-8//IGNORE', $this->body); + $body = @iconv($this->charset, 'UTF-8//IGNORE', $this->body); if (empty($body)) { return; } @@ -433,7 +433,7 @@ class BananaMimePart $signed =& $this->getSignedPart(); if ($signed !== $this) { return $signed->getText(); - } + } $this->decodeContent(); return $this->body; } @@ -452,6 +452,15 @@ class BananaMimePart 'artid' => Banana::$artid, 'part' => $part))) . '" alt="' . banana_htmlentities($this->filename) . '" />'; + } else if ($type == 'multipart' && $subtype == 'alternative') { + $types =& Banana::$msgshow_mimeparts; + foreach ($types as $type) { + @list($type, $subtype) = explode('/', $type); + $part = $this->getParts($type, $subtype); + if (count($part) > 0) { + return $part[0]->toHtml(); + } + } } elseif ((!in_array($type, Banana::$msgshow_mimeparts) && !in_array($this->content_type, Banana::$msgshow_mimeparts)) || $this->disposition == 'attachment') { @@ -643,15 +652,20 @@ class BananaMimePart private function checkPGPSignature($signature, $message = null) { + if (!Banana::$msgshow_pgpcheck) { + return true; + } $signname = tempnam(Banana::$spool_root, 'banana_pgp_'); + $gpg = 'LC_ALL="en_US" ' . Banana::$msgshow_pgppath . ' ' . Banana::$msgshow_pgpoptions . ' --verify ' + . $signname . '.asc '; file_put_contents($signname. '.asc', $signature); $gpg_check = array(); if (!is_null($message)) { file_put_contents($signname, str_replace(array("\r\n", "\n"), array("\n", "\r\n"), $message)); - exec('LC_ALL="en_US" gpg --verify ' . $signname . '.asc ' . $signname . ' 2>&1', $gpg_check, $result); + exec($gpg . $signname . ' 2>&1', $gpg_check, $result); unlink($signname); } else { - exec('LC_ALL="en_US" gpg --verify ' . $signname . '.asc 2&>1', $gpg_check, $result); + exec($gpg . '2&>1', $gpg_check, $result); } unlink("$signname.asc"); if (preg_match('/Signature made (.+) using (.+) key ID (.+)/', array_shift($gpg_check), $matches)) { @@ -665,9 +679,11 @@ class BananaMimePart if (preg_match('/Good signature from "(.+)"/', $signature, $matches)) { $this->signature['verify'] = true; $this->signature['identity'] = array($matches[1]); + $this->signature['certified'] = true; } elseif (preg_match('/BAD signature from "(.+)"/', $signature, $matches)) { $this->signature['verify'] = false; $this->signature['identity'] = array($matches[1]); + $this->signature['certified'] = false; } else { return false; } @@ -675,6 +691,10 @@ class BananaMimePart if (preg_match('/aka "(.+)"/', $aka, $matches)) { $this->signature['identity'][] = $matches[1]; } + if (preg_match('/This key is not certified with a trusted signature!/', $aka)) { + $this->signature['certified'] = false; + $this->signature['certification_error'] = _b_("identité non confirmée"); + } } return true; }