[imp] Patch: pgp-key with parenthesis in comment
W. Tasin
tasin at fhm.edu
Wed Apr 7 08:50:19 PDT 2004
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
-------------- next part --------------
--- 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:')) {
More information about the imp
mailing list