[prev in list] [next in list] [prev in thread] [next in thread] 

List:       imp
Subject:    [imp] Patch: pgp-key with parenthesis in comment
From:       "W. Tasin" <tasin () fhm ! edu>
Date:       2004-04-07 15:50:19
Message-ID: 4074233B.9010703 () fhm ! edu
[Download RAW message or body]

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


["Crypt_pgp.diff" (text/plain)]

--- 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:')) {



-- 
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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic