From faa61b929fc4f0e4a2170d79c2a6a0d56792ff10 Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Thu, 2 Jan 2025 02:27:58 -0800 Subject: sus parsing artefact --- inbox_settings.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'inbox_settings.php') diff --git a/inbox_settings.php b/inbox_settings.php index 4e7b24f..5e96974 100644 --- a/inbox_settings.php +++ b/inbox_settings.php @@ -375,20 +375,24 @@ class inbox_settings extends rcube_plugin { $parsed_keys = []; $fingerprint = null; - $data_message = new OpenPGP_Message(); + $data_message = null; 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_message->to_bytes()]; + if (!is_null($fingerprint) && !empty($data_message->packets)) + $parsed_keys[] = [ + 'fingerprint' => $fingerprint, + 'data_blob' => $data_message->to_bytes()]; + $fingerprint = $data_packet->fingerprint; $data_message = new OpenPGP_Message(); - } else if (!($data_packet instanceof OpenPGP_UserIDPacket) + } else if ((!($data_packet instanceof OpenPGP_UserIDPacket) && !($data_packet instanceof OpenPGP_SignaturePacket) - && !($data_packet instanceof OpenPGP_PublicSubkeyPacket)) { + && !($data_packet instanceof OpenPGP_PublicSubkeyPacket)) + || is_null($fingerprint)) { // ignore unknown packet types for the time being continue; } -- cgit v1.2.3