Changeset 8d553bf for perl


Ignore:
Timestamp:
Feb 5, 2011, 11:28:27 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
8061a6a
Parents:
099597c
git-author:
Adam Glasgall <adam@crossproduct.net> (02/04/11 19:26:33)
git-committer:
David Benjamin <davidben@mit.edu> (02/05/11 23:28:27)
Message:
Append sender's realm to Cc'd unqualified names when replying

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.

[davidben@mit.edu: Fix up some edge case handling]
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl/Message/Zephyr.pm

    r1522e5d r8d553bf  
    1515    $sender =~ s/\@\Q$realm\E$//;
    1616    return $sender;
     17}
     18
     19sub principal_realm {
     20    my $principal = shift;
     21    my ($user, $realm) = split(/@/,$principal);
     22    return $realm;
    1723}
    1824
     
    184190
    185191    push @cmd, context_reply_cmd($class, $instance);
     192
    186193    if ($to ne '') {
    187194        $to = strip_realm($to);
     
    189196            my @cc = grep /^[^-]/, ($to, split /\s+/, $cc);
    190197            my %cc = map {$_ => 1} @cc;
     198            # this isn't quite right - it doesn't strip off the
     199            # user if the message was addressed to them by fully qualified
     200            # name
    191201            delete $cc{strip_realm(BarnOwl::zephyr_getsender())};
    192202            @cc = keys %cc;
     203
     204            my $sender_realm = principal_realm($self->sender);
     205            if (BarnOwl::zephyr_getrealm() ne $sender_realm) {
     206                @cc = map {
     207                    if($_ !~ /@/) {
     208                       "${_}\@${sender_realm}";
     209                    } else {
     210                        $_;
     211                    }
     212                } @cc;
     213            }
    193214            push @cmd, '-C', @cc;
    194215        } else {
Note: See TracChangeset for help on using the changeset viewer.