From: Michael M Slusarz Date: Mon, 15 Dec 2008 18:49:42 +0000 (-0700) Subject: Don't add empty part at end of data. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1b99634ca2b14399d1e183a6a3cf25f89964a841;p=horde.git Don't add empty part at end of data. --- diff --git a/framework/Crypt/lib/Horde/Crypt/pgp.php b/framework/Crypt/lib/Horde/Crypt/pgp.php index a43d2f21d..bb525a968 100644 --- a/framework/Crypt/lib/Horde/Crypt/pgp.php +++ b/framework/Crypt/lib/Horde/Crypt/pgp.php @@ -1,5 +1,4 @@ _tempdir = Util::createTempDir(true, $params['temp']); @@ -683,7 +682,7 @@ class Horde_Crypt_pgp extends Horde_Crypt public function parsePGPData($text) { $data = array(); - $temp_array = array( + $temp = array( 'type' => self::ARMOR_TEXT ); @@ -691,25 +690,26 @@ class Horde_Crypt_pgp extends Horde_Crypt 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;