From 71466fedc7a8c82a1a7157ccb637749e7f4700c1 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 9 Nov 2009 15:11:22 -0700 Subject: [PATCH] Remove x-imp-pgp-signature Content-Type hack --- imp/lib/Mime/Viewer/Pgp.php | 14 +++----------- imp/lib/Mime/Viewer/Plain.php | 8 +++++++- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/imp/lib/Mime/Viewer/Pgp.php b/imp/lib/Mime/Viewer/Pgp.php index c29ca1f21..583404f6b 100644 --- a/imp/lib/Mime/Viewer/Pgp.php +++ b/imp/lib/Mime/Viewer/Pgp.php @@ -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; diff --git a/imp/lib/Mime/Viewer/Plain.php b/imp/lib/Mime/Viewer/Plain.php index bdd72f5d6..a890c8dc6 100644 --- a/imp/lib/Mime/Viewer/Plain.php +++ b/imp/lib/Mime/Viewer/Plain.php @@ -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); -- 2.11.0