From imp Wed Apr 07 15:50:19 2004 From: "W. Tasin" Date: Wed, 07 Apr 2004 15:50:19 +0000 To: imp Subject: [imp] Patch: pgp-key with parenthesis in comment Message-Id: <4074233B.9010703 () fhm ! edu> X-MARC-Message: https://marc.info/?l=imp&m=108135311111378 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------050406020609090103030803" This is a multi-part message in MIME format. --------------050406020609090103030803 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi list, here's another patch concering the parsing of parenthesis in the "comment" of a (g|p)gp-key. Incidentally I entered a parenthesis in the comment field on the key generation form. The key was successfully created, but the details didn't show a correct email address, so imp wasn't able to display and to export to turba. Here's the patch for it. Ciao Walter --------------050406020609090103030803 Content-Type: text/plain; name="Crypt_pgp.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Crypt_pgp.diff" --- framework/Crypt/Crypt/pgp.php Thu Jan 1 16:14:14 2004 +++ framework/Crypt/Crypt/pgp.php Wed Apr 7 16:33:36 2004 @@ -312,11 +312,17 @@ } elseif (stristr($line, ':user ID packet:')) { $uid_idx++; $line = preg_replace_callback('/\\\\x([0-9a-f]{2})/', create_function('$a', 'return chr(hexdec($a[1]));'), $line); - if (preg_match("/\"([^\(\<]+)\s+(?:\(([^\)]*)\))*\s*\<([^\>]+)\>\"/", $line, $matches)) { + if (preg_match("/\"([^\<]+)\<([^\>]+)\>\"/", $line, $matches)) { $header = 'id' . $uid_idx; - $data_array['signature'][$header]['name'] = $matches[1]; - $data_array['signature'][$header]['comment'] = $matches[2]; - $data_array['signature'][$header]['email'] = $matches[3]; + if (preg_match('/([^\(]+)\((.+)\)$/', trim($matches[1]), $comment_matches)) { + $data_array['signature'][$header]['name'] = trim($comment_matches[1]); + $data_array['signature'][$header]['comment'] = $comment_matches[2]; + + } else { + $data_array['signature'][$header]['name'] = trim($matches[1]); + $data_array['signature'][$header]['comment'] = ''; + } + $data_array['signature'][$header]['email'] = $matches[2]; $data_array['signature'][$header]['fingerprint'] = $fingerprint; } } elseif (stristr($line, ':signature packet:')) { --------------050406020609090103030803 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- IMP mailing list - Join the hunt: http://horde.org/bounties/#imp Frequently Asked Questions: http://horde.org/faq/ To unsubscribe, mail: imp-unsubscribe@lists.horde.org --------------050406020609090103030803--