Fix boundary separator in signed messages

pull/322/head
Aleksander Machniak 9 years ago
parent 0e77b6f1b3
commit c7af660bfc

@ -142,6 +142,8 @@ class enigma_mime_message extends Mail_mime
public function addPGPSignature($body) public function addPGPSignature($body)
{ {
$this->signature = $body; $this->signature = $body;
// Reset Content-Type to be overwritten with valid boundary
unset($this->headers['Content-Type']);
} }
/** /**
@ -152,6 +154,8 @@ class enigma_mime_message extends Mail_mime
public function setPGPEncryptedBody($body) public function setPGPEncryptedBody($body)
{ {
$this->encrypted = $body; $this->encrypted = $body;
// Reset Content-Type to be overwritten with valid boundary
unset($this->headers['Content-Type']);
} }
/** /**
@ -177,13 +181,13 @@ class enigma_mime_message extends Mail_mime
$this->checkParams(); $this->checkParams();
if ($this->type == self::PGP_SIGNED) { if ($this->type == self::PGP_SIGNED) {
$body = "This is an OpenPGP/MIME signed message (RFC 4880 and 3156)";
$params = array( $params = array(
'preamble' => "This is an OpenPGP/MIME signed message (RFC 4880 and 3156)",
'content_type' => "multipart/signed; micalg=pgp-sha1; protocol=\"application/pgp-signature\"", 'content_type' => "multipart/signed; micalg=pgp-sha1; protocol=\"application/pgp-signature\"",
'eol' => $this->build_params['eol'], 'eol' => $this->build_params['eol'],
); );
$message = new Mail_mimePart($body, $params); $message = new Mail_mimePart('', $params);
if (!empty($this->body)) { if (!empty($this->body)) {
$headers = $this->message->headers(); $headers = $this->message->headers();
@ -206,13 +210,13 @@ class enigma_mime_message extends Mail_mime
} }
} }
else if ($this->type == self::PGP_ENCRYPTED) { else if ($this->type == self::PGP_ENCRYPTED) {
$body = "This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)";
$params = array( $params = array(
'preamble' => "This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)",
'content_type' => "multipart/encrypted; protocol=\"application/pgp-encrypted\"", 'content_type' => "multipart/encrypted; protocol=\"application/pgp-encrypted\"",
'eol' => $this->build_params['eol'], 'eol' => $this->build_params['eol'],
); );
$message = new Mail_mimePart($body, $params); $message = new Mail_mimePart('', $params);
$message->addSubpart('Version: 1', array( $message->addSubpart('Version: 1', array(
'content_type' => 'application/pgp-encrypted', 'content_type' => 'application/pgp-encrypted',

Loading…
Cancel
Save