[Pgp-tools-commit] r15 - trunk/caff

Peter Palfrader weasel at haydn.debian.org
Sat Jul 3 12:18:01 UTC 2004


Author: weasel
Date: 2004-07-03 06:17:48 -0600 (Sat, 03 Jul 2004)
New Revision: 15

Modified:
   trunk/caff/TODO
   trunk/caff/caff
Log:
replace :, / and \ in filenames for uids with underscores

Modified: trunk/caff/TODO
===================================================================
--- trunk/caff/TODO	2004-07-03 11:11:53 UTC (rev 14)
+++ trunk/caff/TODO	2004-07-03 12:17:48 UTC (rev 15)
@@ -7,4 +7,3 @@
         X Abandoned
 
 - need to import own keys into our gnupghome
-- replace / in filesnames (from UIDs) with _

Modified: trunk/caff/caff
===================================================================
--- trunk/caff/caff	2004-07-03 11:11:53 UTC (rev 14)
+++ trunk/caff/caff	2004-07-03 12:17:48 UTC (rev 15)
@@ -443,6 +443,14 @@
 	$message_entity->stringify();
 };
 
+sub sanitize_uid($) {
+	my ($uid) = @_;
+
+	my $good_uid =~ tr#/:\\#_#;
+	trace2("[sanitize_uid] changed UID from $uid to $good_uid.\n") if $good_uid ne $uid;
+	return $good_uid;
+};
+
 my $USER;
 my @KEYIDS;
 
@@ -684,7 +692,7 @@
 			my $keydir = "$KEYSBASE/$DATE_STRING";
 			-d $keydir  || mkpath($keydir , 0, 0700) or die ("Cannot create $keydir $!\n");
 
-			my $keyfile = "$keydir/$longkeyid.key.$uid_number.$this_uid_text.asc";
+			my $keyfile = "$keydir/$longkeyid.key.$uid_number.".sanitize_uid($this_uid_text).".asc";
 			open (KEY, ">$keyfile") or die ("Cannot open $keyfile\n");
 			print KEY $asciikey;
 			close KEY;
@@ -702,6 +710,7 @@
 	} else {
 		my @attached ;
 		for my $uid (@UIDS) {
+			trace("UID: $uid->{'text'}\n");
 			unless ($uid->{'text'} =~ /@/) {
 				my $attach = ask("UID $uid->{'text'} is no email address, attach it to every email sent?", 1);
 				push @attached, $uid;
@@ -718,7 +727,7 @@
 					my $mail = send_mail($address, $can_encrypt, $longkeyid, $uid, @attached);
 
 					my $keydir = "$KEYSBASE/$DATE_STRING";
-					my $mailfile = "$keydir/$longkeyid.mail.".$uid->{'serial'}.".".$uid->{'text'};
+					my $mailfile = "$keydir/$longkeyid.mail.".$uid->{'serial'}.".".sanitize_uid($uid->{'text'});
 					open (KEY, ">$mailfile") or die ("Cannot open $mailfile\n");
 					print KEY $mail;
 					close KEY;





More information about the Pgp-tools-commit mailing list