[2881] in BarnOwl Developers
[PATCH] Append sender's realm to Cc'd unqualified names when replying
daemon@ATHENA.MIT.EDU (Adam Glasgall)
Fri Feb 4 19:26:46 2011
From: Adam Glasgall <adam@crossproduct.net>
To: barnowl-dev@mit.edu
Cc: Adam Glasgall <adam@crossproduct.net>
Date: Fri, 4 Feb 2011 19:26:33 -0500
Currently, if you reply to a personal from a user in another realm,
that message was Cc'd to other people on their realm, and the sender
didn't specify their realm, Barnowl will try to Cc the message to
users of the same name in your realm. So, if you are 'bar@EXAMPLE.ORG'
and you get a message from 'foo@EXAMPLE.COM' cc'd to 'bletch', if you
try to reply, Barnowl will address it to foo@EXAMPLE.COM, cc'd to
'bletch', which would be bletch@EXAMPLE.ORG, which is clearly
wrong. This patch appends the sender's realm to unqualified names in
the message's Cc line when generating the reply zwrite command line.
---
perl/lib/BarnOwl/Message/Zephyr.pm | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/perl/lib/BarnOwl/Message/Zephyr.pm b/perl/lib/BarnOwl/Message/Zephyr.pm
index 83fabba..89a8bb5 100644
--- a/perl/lib/BarnOwl/Message/Zephyr.pm
+++ b/perl/lib/BarnOwl/Message/Zephyr.pm
@@ -16,6 +16,12 @@ sub strip_realm {
return $sender;
}
+sub principal_realm {
+ my $principal = shift;
+ my ($user, $realm) = split(/@/,$principal);
+ return $realm;
+}
+
sub login_type {
return (shift->zsig eq "") ? "(PSEUDO)" : "";
}
@@ -183,13 +189,29 @@ sub replycmd {
}
push @cmd, context_reply_cmd($class, $instance);
+
if ($to ne '') {
+ my $sender_realm = principal_realm($to);
$to = strip_realm($to);
if (defined $cc and not $sender) {
my @cc = grep /^[^-]/, ($to, split /\s+/, $cc);
my %cc = map {$_ => 1} @cc;
+ # this isn't quite right - it doesn't strip off the
+ # user if the message was addressed to them by fully qualified
+ # name
delete $cc{strip_realm(BarnOwl::zephyr_getsender())};
@cc = keys %cc;
+ my $realm = BarnOwl::zephyr_getrealm();
+
+ if($sender !~ /\@\Q$realm\E$/) {
+ @cc = map {
+ if($_ !~ /@/) {
+ "${_}\@${sender_realm}";
+ } else {
+ $_;
+ }
+ } @cc;
+ }
push @cmd, '-C', @cc;
} else {
if(BarnOwl::getvar('smartstrip') eq 'on') {
--
1.7.1