Skip to content

Commit

Permalink
Fix string representation of signed message and literal data
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Apr 14, 2015
1 parent 7691935 commit e9e627b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 7 additions & 4 deletions framework/Pgp/lib/Horde/Pgp/Element/SignedMessage.php
Expand Up @@ -47,7 +47,7 @@ public function __construct($data, array $headers = array())

$msg[] = new OpenPGP_LiteralDataPacket(
substr($data, 0, $pos),
array('format' => 't')
array('format' => 'u')
);
$msg[] = Horde_Pgp_Element_Signature::create(
substr($data, $pos) . "-----END PGP SIGNATURE-----\n"
Expand All @@ -63,10 +63,13 @@ public function __construct($data, array $headers = array())
*/
public function __toString()
{
$out = parent::__toString();
$out = "-----BEGIN PGP SIGNED MESSAGE-----\n";
foreach (array_intersect_key($this->headers, array('Hash' => true)) as $key => $val) {
$out .= $key . ': ' . $val . "\n";
}

/* Remove trailing END SIGNED MESSAGE armor. */
return substr($out, 0, strrpos($out, '-----END'));
return $out . "\n" . str_replace("\r\n", "\n", strval($this->text)) .
"\n" . strval($this->signature);
}

/**
Expand Down
7 changes: 7 additions & 0 deletions framework/Pgp/lib/Horde/Pgp/Element/Text.php
Expand Up @@ -23,4 +23,11 @@
class Horde_Pgp_Element_Text
extends Horde_Pgp_Element
{
/**
*/
public function __toString()
{
return $this->message[0]->data;
}

}

0 comments on commit e9e627b

Please sign in to comment.