<?php
-
/**
* Horde_Crypt_pgp:: provides a framework for Horde applications to interact
* with the GNU Privacy Guard program ("GnuPG"). GnuPG implements the OpenPGP
* binary (key = 'program') and to a temporary
* directory.
*/
- function __construct($params = array())
+ public function __construct($params = array())
{
$this->_tempdir = Util::createTempDir(true, $params['temp']);
public function parsePGPData($text)
{
$data = array();
- $temp_array = array(
+ $temp = array(
'type' => self::ARMOR_TEXT
);
while (list(,$val) = each($buffer)) {
$val = rtrim($val, "\r");
if (preg_match('/^-----(BEGIN|END) PGP ([^-]+)-----\s*$/', $val, $matches)) {
- if (isset($temp_array['data'])) {
- $data[] = $temp_array;
+ if (isset($temp['data'])) {
+ $data[] = $temp;
}
- $temp_array = array();
+ $temp= array();
if ($matches[1] == 'BEGIN') {
- $temp_array['type'] = $this->_armor[$matches[2]];
- $temp_array['data'][] = $val;
+ $temp['type'] = $this->_armor[$matches[2]];
+ $temp['data'][] = $val;
} elseif ($matches[1] == 'END') {
- $temp_array['type'] = self::ARMOR_TEXT;
+ $temp['type'] = self::ARMOR_TEXT;
$data[count($data) - 1]['data'][] = $val;
}
} else {
- $temp_array['data'][] = $val;
+ $temp['data'][] = $val;
}
}
- if (isset($temp_array['data'])) {
- $data[] = $temp_array;
+ if (isset($temp['data']) &&
+ ((count($temp['data']) > 1) || !empty($temp['data'][0]))) {
+ $data[] = $temp;
}
return $data;