diff options
| author | Carson Fleming <[email protected]> | 2025-01-01 22:59:37 -0800 |
|---|---|---|
| committer | Carson Fleming <[email protected]> | 2025-01-01 22:59:37 -0800 |
| commit | 387e6f45dd081f927ddb3c8028bda54a17a9fe2e (patch) | |
| tree | 5221ea3142093e5d532fc1ed93845083fce9e180 | |
| parent | 1a93a383eab4c161a67a32e9dc715f6ee6106699 (diff) | |
| download | rc-inbox-settings-387e6f45dd081f927ddb3c8028bda54a17a9fe2e.tar.gz | |
better pgp parsing
| -rw-r--r-- | inbox_settings.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/inbox_settings.php b/inbox_settings.php index 27480bc..1a6bfdb 100644 --- a/inbox_settings.php +++ b/inbox_settings.php @@ -370,16 +370,17 @@ class inbox_settings extends rcube_plugin { $parsed_keys = []; $fingerprint = null; - $data_blob = ''; + $data_message = new OpenPGP_Message(); foreach ($parsed_data->packets as $data_packet) { if ($data_packet instanceof OpenPGP_SecretKeyPacket) throw new IllegalArgumentException('Input data contains private keys.'); if ($data_packet instanceof OpenPGP_PublicKeyPacket && !($data_packet instanceof OpenPGP_PublicSubkeyPacket)) { - $parsed_keys[] = ['fingerprint' => $fingerprint, 'data_blob' => $data_blob]; + $parsed_keys[] = [ + 'fingerprint' => $fingerprint, 'data_blob' => $data_message->to_bytes()]; $fingerprint = $data_packet->fingerprint; - $data_blob = ''; + $data_message = new OpenPGP_Message(); } else if (!($data_packet instanceof OpenPGP_UserIDPacket) && !($data_packet instanceof OpenPGP_SignaturePacket) && !($data_packet instanceof OpenPGP_PublicSubkeyPacket)) { @@ -387,11 +388,12 @@ class inbox_settings extends rcube_plugin { continue; } - $data_blob .= $data_packet->to_bytes(); + $data_message[] = $data_packet; } - if (!is_null($fingerprint) && !empty($data_blob)) { - $parsed_keys[] = ['fingerprint' => $fingerprint, 'data_blob' => $data_blob]; + if (!is_null($fingerprint) && !empty($data_message->packets)) { + $parsed_keys[] = [ + 'fingerprint' => $fingerprint, 'data_blob' => $data_message->to_bytes()]; } return $parsed_keys; } |
