Remove x-imp-pgp-signature Content-Type hack
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 9 Nov 2009 22:11:22 +0000 (15:11 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 10 Nov 2009 16:48:36 +0000 (09:48 -0700)
imp/lib/Mime/Viewer/Pgp.php
imp/lib/Mime/Viewer/Plain.php

index c29ca1f..583404f 100644 (file)
@@ -349,17 +349,9 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
             $sig_part = $this->_params['contents']->getMIMEPart($sig_id);
 
             try {
-                /* Check for 'x-imp-pgp-signature' type. This is set by the
-                 * 'plain' driver when parsing PGP armor text. */
-                switch ($sig_part->getType()) {
-                case 'application/x-imp-pgp-signature':
-                    $sig_result = $this->_imppgp->verifySignature($sig_part->getContents(array('canonical' => true)), $this->_address);
-                    break;
-
-                default:
-                    $sig_result = $this->_imppgp->verifySignature($sig_part->replaceEOL($this->_params['contents']->getBodyPart($signed_id, array('mimeheaders' => true)), Horde_Mime_Part::RFC_EOL), $this->_address, $sig_part->getContents());
-                    break;
-                }
+                $sig_result = $sig_part->getMetadata('imp-pgp-signature')
+                    ? $this->_imppgp->verifySignature($sig_part->getContents(array('canonical' => true)), $this->_address)
+                    : $this->_imppgp->verifySignature($sig_part->replaceEOL($this->_params['contents']->getBodyPart($signed_id, array('mimeheaders' => true)), Horde_Mime_Part::RFC_EOL), $this->_address, $sig_part->getContents());
 
                 $icon = Horde::img('alerts/success.png', _("Success"), null, $graphicsdir);
                 $sig_text = $sig_result->message;
index bdd72f5..a890c8d 100644 (file)
@@ -234,8 +234,14 @@ class IMP_Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Plain
                     $part1->setContents(substr($part1_data, strpos($part1_data, "\n\n") + 2));
 
                     $part2 = new Horde_Mime_Part();
-                    $part2->setType('application/x-imp-pgp-signature');
+                    $part2->setType('application/pgp-signature');
                     $part2->setContents(Horde_String::convertCharset(implode("\n", $val['data']) . "\n" . implode("\n", $sig['data']), $charset));
+                    // A true pgp-signature part would only contain the
+                    // detached signature. However, we need to carry around
+                    // the entire armored text to verify correctly. Use a
+                    // IMP-specific content-type parameter to clue the PGP
+                    // driver into this fact.
+                    $part2->setMetadata('imp-pgp-signature', true);
 
                     $part->addPart($part1);
                     $part->addPart($part2);