[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.7-284-g1a39d6f
Ruslan Zakirov
ruz at bestpractical.com
Fri Mar 26 05:53:38 EDT 2010
The branch, 3.8-trunk has been updated
via 1a39d6f96a221c2507319f932101c720a7a732c7 (commit)
via 30bb2bb98f1fee182d2c7bf7261dbd5f2f3cd9c0 (commit)
via 30f45d6a8cc3836fe1bf45b4c01eaea97877ebe3 (commit)
via a379f9daa08d45f76610b6a1c4bd3ce8130ae59b (commit)
via d175e86048879f70dbb2a5dbb43d38a5664819ab (commit)
via e3ebff1df81860b0c8ed69730e03c9aa27ba886a (commit)
via 2f11e5d2a96d5a099ae6ee2495c7f1e1f36b0857 (commit)
via f58ed809f160baddae260ae5f7d89f6e9a5013a6 (commit)
via c70db9a9288d90ca73c7c78b0e30d558c17eea8f (commit)
via dde3b3afc146f056693d81dcc6b426c9a6038a75 (commit)
via d27eef5a57b2d6abba96da6f93d6cbddd4e8d24b (commit)
via 9bc63f712a807009775298fb0374ebd94e2632c5 (commit)
from a2ff1fe108a829a16ec8803097663606849667af (commit)
Summary of changes:
lib/RT/Attachment_Overlay.pm | 14 +++------
lib/RT/Config.pm | 20 +++++++++++++-
lib/RT/EmailParser.pm | 35 ++++++++++++++----------
lib/RT/Interface/Email.pm | 20 ++++----------
lib/RT/Queue_Overlay.pm | 7 +++++
lib/RT/Scrip_Overlay.pm | 13 +++++++++
lib/RT/Ticket_Overlay.pm | 8 +++++
share/html/Admin/Queues/Modify.html | 7 +++++
share/html/Ticket/Create.html | 5 +---
share/html/Ticket/Update.html | 5 +---
t/ticket/merge.t | 49 +++++++++++++++++++++++++++++++++-
11 files changed, 133 insertions(+), 50 deletions(-)
- Log -----------------------------------------------------------------
commit 9bc63f712a807009775298fb0374ebd94e2632c5
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Feb 16 21:01:33 2010 +0300
use IsRTAddress on Create/Update
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index eeff899..2c8e357 100755
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -396,15 +396,12 @@ if ( !exists $ARGS{'AddMoreAttach'} && ($ARGS{'id'}||'') eq 'new' ) {
# check email addresses for RT's
{
- my $address_re = RT->Config->Get('RTAddressRegexp');
foreach my $field ( qw(Requestors Cc AdminCc) ) {
my $value = $ARGS{ $field };
next unless defined $value && length $value;
my @emails = Email::Address->parse( $value );
- foreach my $email ( @emails ) {
- next unless $email->address =~ $address_re;
-
+ foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
push @results, loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email->format, loc($field =~ /^(.*?)s?$/) );
$checks_failure = 1;
$email = undef;
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 9bce7de..18f8d60 100755
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -264,15 +264,12 @@ if ( $ARGS{'SubmitTicket'} ) {
# check email addresses for RT's
{
- my $address_re = RT->Config->Get('RTAddressRegexp');
foreach my $field ( qw(UpdateCc UpdateBcc) ) {
my $value = $ARGS{ $field };
next unless defined $value && length $value;
my @emails = Email::Address->parse( $value );
- foreach my $email ( @emails ) {
- next unless $email->address =~ $address_re;
-
+ foreach my $email ( grep RT::EmailAddress->IsRTAddress($_->address), @emails ) {
push @results, loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email->format, loc(substr($field, 6)) );
$checks_failure = 1;
$email = undef;
commit d27eef5a57b2d6abba96da6f93d6cbddd4e8d24b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Feb 16 21:04:29 2010 +0300
don't generate lame regexp for RTAddressRegexp
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 2604a24..cc4b1c1 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -333,6 +333,21 @@ our %META = (
},
},
+ RTAddressRegexp => {
+ Type => 'SCALAR',
+ PostLoadCheck => sub {
+ my $self = shift;
+ my $value = $self->Get('RTAddressRegexp');
+ return if $value;
+
+ $RT::Logger->error(
+ 'RTAddressRegexp option is not set in the config.'
+ .' Not setting this option result in additional SQL queries to check'
+ .' every address if it belongs to RT or not. These checks are'
+ .' required to avoid mail loops and other consequences.'
+ );
+ },
+ },
# User overridable mail options
EmailFrequency => {
Section => 'Mail', #loc
@@ -829,9 +844,9 @@ sub SetFromConfig {
# get entry for type we are looking for
# XXX skip references to scalars or other references.
- # Otherwise 5.10 goes boom. maybe we should skip any
+ # Otherwie 5.10 goes boom. may be we should skip any
# reference
- next if ref($entry) eq 'SCALAR' || ref($entry) eq 'REF';
+ return if ref($entry) eq 'SCALAR' || ref($entry) eq 'REF';
my $entry_ref = *{$entry}{ ref($ref) };
next unless $entry_ref;
commit dde3b3afc146f056693d81dcc6b426c9a6038a75
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Feb 16 21:06:29 2010 +0300
if RT address regexp is not set then load queues for check
diff --git a/lib/RT/EmailParser.pm b/lib/RT/EmailParser.pm
index 7890f49..88041fe 100755
--- a/lib/RT/EmailParser.pm
+++ b/lib/RT/EmailParser.pm
@@ -333,12 +333,18 @@ sub IsRTAddress {
my $self = shift;
my $address = shift;
- # Example: the following rule would tell RT not to Cc
- # "tickets at noc.example.com"
- my $address_re = RT->Config->Get('RTAddressRegexp');
- if ( defined $address_re && $address =~ /$address_re/i ) {
- return 1;
+ if ( my $address_re = RT->Config->Get('RTAddressRegexp') ) {
+ return $address =~ /$address_re/i ? 1 : undef;
}
+
+ # we don't warn here, but do in config check
+ my $queue = RT::Queue->new( $RT::SystemUser );
+ $queue->LoadByCols( CorrespondAddress => $address );
+ return 1 if $queue->id;
+
+ $queue->LoadByCols( CommentAddress => $address );
+ return 1 if $queue->id;
+
return undef;
}
commit c70db9a9288d90ca73c7c78b0e30d558c17eea8f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Feb 16 21:11:10 2010 +0300
match against global Comment/Correspond addresses
diff --git a/lib/RT/EmailParser.pm b/lib/RT/EmailParser.pm
index 88041fe..5445080 100755
--- a/lib/RT/EmailParser.pm
+++ b/lib/RT/EmailParser.pm
@@ -338,6 +338,13 @@ sub IsRTAddress {
}
# we don't warn here, but do in config check
+ if ( my $global_address = RT->Config->Get('CorrespondAddress') ) {
+ return 1 if lc $global_address eq lc $address;
+ }
+ if ( my $global_address = RT->Config->Get('CommentAddress') ) {
+ return 1 if lc $global_address eq lc $address;
+ }
+
my $queue = RT::Queue->new( $RT::SystemUser );
$queue->LoadByCols( CorrespondAddress => $address );
return 1 if $queue->id;
@@ -349,8 +356,6 @@ sub IsRTAddress {
}
-
-
=head2 CullRTAddresses ARRAY
Takes a single argument, an array of email addresses.
commit f58ed809f160baddae260ae5f7d89f6e9a5013a6
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Feb 16 21:13:30 2010 +0300
change every usage of the IsRTAddress function
diff --git a/lib/RT/Attachment_Overlay.pm b/lib/RT/Attachment_Overlay.pm
index e709814..e2707a7 100644
--- a/lib/RT/Attachment_Overlay.pm
+++ b/lib/RT/Attachment_Overlay.pm
@@ -447,24 +447,20 @@ sub Addresses {
my %data = ();
my $current_user_address = lc $self->CurrentUser->EmailAddress;
- my $correspond = lc $self->TransactionObj->TicketObj->QueueObj->CorrespondAddress;
- my $comment = lc $self->TransactionObj->TicketObj->QueueObj->CommentAddress;
foreach my $hdr (qw(From To Cc Bcc RT-Send-Cc RT-Send-Bcc)) {
my @Addresses;
- my $line = $self->GetHeader($hdr);
+ my $line = $self->GetHeader($hdr);
foreach my $AddrObj ( Email::Address->parse( $line )) {
my $address = $AddrObj->address;
$address = lc RT::User->CanonicalizeEmailAddress($address);
- next if ( $current_user_address eq $address );
- next if ( $comment eq $address );
- next if ( $correspond eq $address );
- next if ( RT::EmailParser->IsRTAddress($address) );
+ next if $current_user_address eq $address;
+ next if RT::EmailParser->IsRTAddress($address);
push @Addresses, $AddrObj ;
}
- $data{$hdr} = \@Addresses;
+ $data{$hdr} = \@Addresses;
}
- return \%data;
+ return \%data;
}
=head2 NiceHeaders
diff --git a/lib/RT/EmailParser.pm b/lib/RT/EmailParser.pm
index 5445080..036743f 100755
--- a/lib/RT/EmailParser.pm
+++ b/lib/RT/EmailParser.pm
@@ -289,9 +289,7 @@ email address and anything that the RT->Config->Get('RTAddressRegexp') matches.
=cut
sub ParseCcAddressesFromHead {
-
my $self = shift;
-
my %args = (
QueueObj => undef,
CurrentUser => undef,
@@ -307,10 +305,8 @@ sub ParseCcAddressesFromHead {
my $Address = $AddrObj->address;
my $user = RT::User->new($RT::SystemUser);
$Address = $user->CanonicalizeEmailAddress($Address);
- next if ( lc $args{'CurrentUser'}->EmailAddress eq lc $Address );
- next if ( lc $args{'QueueObj'}->CorrespondAddress eq lc $Address );
- next if ( lc $args{'QueueObj'}->CommentAddress eq lc $Address );
- next if ( $self->IsRTAddress($Address) );
+ next if lc $args{'CurrentUser'}->EmailAddress eq lc $Address;
+ next if $self->IsRTAddress($Address) );
push ( @Addresses, $Address );
}
@@ -318,8 +314,6 @@ sub ParseCcAddressesFromHead {
}
-
-
=head2 IsRTaddress ADDRESS
Takes a single parameter, an email address.
diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 6df907c..e0815fb 100755
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -978,22 +978,14 @@ sub ParseCcAddressesFromHead {
@_
);
- my @recipients =
- map lc $_->address,
+ my $current_address = lc $args{'CurrentUser'}->EmailAddress;
+ my $user = $args{'CurrentUser'}->UserObj;
+
+ return
+ grep $_ ne $current_address && !RT::EmailParser->IsRTAddress( $_ ),
+ map lc $user->CanonicalizeEmailAddress( $_->address ),
map Email::Address->parse( $args{'Head'}->get( $_ ) ),
qw(To Cc);
-
- my @res;
- foreach my $address ( @recipients ) {
- $address = $args{'CurrentUser'}->UserObj->CanonicalizeEmailAddress( $address );
- next if lc $args{'CurrentUser'}->EmailAddress eq $address;
- next if lc $args{'QueueObj'}->CorrespondAddress eq $address;
- next if lc $args{'QueueObj'}->CommentAddress eq $address;
- next if RT::EmailParser->IsRTAddress( $address );
-
- push @res, $address;
- }
- return @res;
}
commit 2f11e5d2a96d5a099ae6ee2495c7f1e1f36b0857
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Feb 16 22:26:58 2010 +0300
adjust warning wording
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index cc4b1c1..f552b0c 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -343,8 +343,9 @@ our %META = (
$RT::Logger->error(
'RTAddressRegexp option is not set in the config.'
.' Not setting this option result in additional SQL queries to check'
- .' every address if it belongs to RT or not. These checks are'
- .' required to avoid mail loops and other consequences.'
+ .' every address if it belongs to RT or not.'
+ .' Especially important to set this option if RT recieves'
+ .' emails on addresses that are not in DB or config.'
);
},
},
commit e3ebff1df81860b0c8ed69730e03c9aa27ba886a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Feb 17 01:22:38 2010 +0300
fix some mistakes
diff --git a/lib/RT/EmailParser.pm b/lib/RT/EmailParser.pm
index 036743f..63c7698 100755
--- a/lib/RT/EmailParser.pm
+++ b/lib/RT/EmailParser.pm
@@ -306,7 +306,7 @@ sub ParseCcAddressesFromHead {
my $user = RT::User->new($RT::SystemUser);
$Address = $user->CanonicalizeEmailAddress($Address);
next if lc $args{'CurrentUser'}->EmailAddress eq lc $Address;
- next if $self->IsRTAddress($Address) );
+ next if $self->IsRTAddress($Address);
push ( @Addresses, $Address );
}
@@ -332,11 +332,11 @@ sub IsRTAddress {
}
# we don't warn here, but do in config check
- if ( my $global_address = RT->Config->Get('CorrespondAddress') ) {
- return 1 if lc $global_address eq lc $address;
+ if ( my $correspond_address = RT->Config->Get('CorrespondAddress') ) {
+ return 1 if lc $correspond_address eq lc $address;
}
- if ( my $global_address = RT->Config->Get('CommentAddress') ) {
- return 1 if lc $global_address eq lc $address;
+ if ( my $comment_address = RT->Config->Get('CommentAddress') ) {
+ return 1 if lc $comment_address eq lc $address;
}
my $queue = RT::Queue->new( $RT::SystemUser );
commit d175e86048879f70dbb2a5dbb43d38a5664819ab
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Feb 18 22:24:49 2010 +0300
don't allow to add RT addresses as watchers in API
this covers Ticket/People page as well
diff --git a/lib/RT/Queue_Overlay.pm b/lib/RT/Queue_Overlay.pm
index 00d684c..98bdec5 100755
--- a/lib/RT/Queue_Overlay.pm
+++ b/lib/RT/Queue_Overlay.pm
@@ -789,8 +789,15 @@ sub _AddWatcher {
my $principal = RT::Principal->new( $self->CurrentUser );
if ( $args{'PrincipalId'} ) {
$principal->Load( $args{'PrincipalId'} );
+ if ( $principal->id and $principal->IsUser and my $email = $principal->Object->EmailAddress ) {
+ return (0, $self->loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email, $self->loc($args{'Type'})))
+ if RT::EmailParser->IsRTAddress( $email );
+ }
}
elsif ( $args{'Email'} ) {
+ if ( RT::EmailParser->IsRTAddress( $args{'Email'} ) ) {
+ return (0, $self->loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $args{'Email'}, $self->loc($args{'Type'})));
+ }
my $user = RT::User->new($self->CurrentUser);
$user->LoadByEmail( $args{'Email'} );
$user->Load( $args{'Email'} )
diff --git a/lib/RT/Ticket_Overlay.pm b/lib/RT/Ticket_Overlay.pm
index c722590..186853e 100755
--- a/lib/RT/Ticket_Overlay.pm
+++ b/lib/RT/Ticket_Overlay.pm
@@ -1103,12 +1103,20 @@ sub _AddWatcher {
my $principal = RT::Principal->new($self->CurrentUser);
if ($args{'Email'}) {
+ if ( RT::EmailParser->IsRTAddress( $args{'Email'} ) ) {
+ return (0, $self->loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $args{'Email'}, $self->loc($args{'Type'})));
+ }
my $user = RT::User->new($RT::SystemUser);
my ($pid, $msg) = $user->LoadOrCreateByEmail( $args{'Email'} );
$args{'PrincipalId'} = $pid if $pid;
}
if ($args{'PrincipalId'}) {
$principal->Load($args{'PrincipalId'});
+ if ( $principal->id and $principal->IsUser and my $email = $principal->Object->EmailAddress ) {
+ return (0, $self->loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email, $self->loc($args{'Type'})))
+ if RT::EmailParser->IsRTAddress( $email );
+
+ }
}
commit a379f9daa08d45f76610b6a1c4bd3ce8130ae59b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Feb 18 22:39:53 2010 +0300
warn admin if RTAddressRegexp is set, but queue's address doesn't match
diff --git a/share/html/Admin/Queues/Modify.html b/share/html/Admin/Queues/Modify.html
index df97a68..c6ffe17 100755
--- a/share/html/Admin/Queues/Modify.html
+++ b/share/html/Admin/Queues/Modify.html
@@ -194,6 +194,13 @@ if ( $QueueObj->Id ) {
);
push @results, @linkresults;
push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $QueueObj );
+ if ( RT->Config->Get('RTAddressRegexp') ) {
+ foreach my $address ( $QueueObj->CorrespondAddress, $QueueObj->CommentAddress ) {
+ next unless defined $address && length $address;
+ next if RT::EmailParser->IsRTAddress( $address );
+ push @results, loc("RTAddressRegexp option in the config doesn't match [_1]", $address );
+ }
+ }
}
</%INIT>
commit 30f45d6a8cc3836fe1bf45b4c01eaea97877ebe3
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Feb 25 23:57:35 2010 +0300
fix typo in class name
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 18f8d60..f5cddde 100755
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -269,7 +269,7 @@ if ( $ARGS{'SubmitTicket'} ) {
next unless defined $value && length $value;
my @emails = Email::Address->parse( $value );
- foreach my $email ( grep RT::EmailAddress->IsRTAddress($_->address), @emails ) {
+ foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
push @results, loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email->format, loc(substr($field, 6)) );
$checks_failure = 1;
$email = undef;
commit 30bb2bb98f1fee182d2c7bf7261dbd5f2f3cd9c0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Mar 25 17:35:39 2010 +0300
test that merge only possible when user has Modify right on both tickets
diff --git a/t/ticket/merge.t b/t/ticket/merge.t
index a714cb6..7c72fe0 100644
--- a/t/ticket/merge.t
+++ b/t/ticket/merge.t
@@ -5,7 +5,7 @@ use warnings;
use RT;
-use RT::Test tests => '17';
+use RT::Test tests => '29';
# validate that when merging two tickets, the comments from both tickets
@@ -16,7 +16,10 @@ use RT::Test tests => '17';
ok ($id,$msg);
my $t1 = RT::Ticket->new($RT::SystemUser);
- my ($tid,$transid, $t1msg) =$t1->Create ( Queue => $queue->Name, Subject => 'Merge test. orig');
+ my ($tid,$transid, $t1msg) =$t1->Create(
+ Queue => $queue->Name,
+ Subject => 'Merge test. orig',
+ );
ok ($tid, $t1msg);
($id, $msg) = $t1->Comment(Content => 'This is a Comment on the original');
ok($id,$msg);
@@ -90,3 +93,45 @@ use RT::Test tests => '17';
($id,$val) = $t->MergeInto($t2->id);
ok($id,$val);
}
+
+my $user = RT::Test->load_or_create_user(
+ Name => 'a user', Password => 'password',
+);
+ok $user && $user->id, 'loaded or created user';
+
+# check rights
+{
+ RT::Test->set_rights(
+ { Principal => 'Everyone', Right => [qw(SeeQueue ShowTicket CreateTicket OwnTicket TakeTicket)] },
+ { Principal => 'Owner', Right => [qw(ModifyTicket)] },
+ );
+
+ my $t = RT::Ticket->new(RT::CurrentUser->new($user));
+ $t->Create(Subject => 'Main', Queue => 'general');
+ ok ($t->id, "Created ticket");
+
+ my $t2 = RT::Ticket->new(RT::CurrentUser->new($user));
+ $t2->Create(Subject => 'Second', Queue => 'general');
+ ok ($t2->id, "Created ticket");
+
+ foreach my $ticket ( $t, $t2 ) {
+ ok( !$ticket->CurrentUserHasRight('ModifyTicket'), "can not modify" );
+ }
+
+ my ($status,$msg) = $t->MergeInto($t2->id);
+ ok(!$status, "Can not merge: $msg");
+
+ ($status, $msg) = $t->SetOwner( $user->id );
+ ok( $status, "User took ticket");
+ ok( $t->CurrentUserHasRight('ModifyTicket'), "can modify after take" );
+
+ ($status,$msg) = $t->MergeInto($t2->id);
+ ok(!$status, "Can not merge: $msg");
+
+ ($status, $msg) = $t2->SetOwner( $user->id );
+ ok( $status, "User took ticket");
+ ok( $t2->CurrentUserHasRight('ModifyTicket'), "can modify after take" );
+
+ ($status,$msg) = $t->MergeInto($t2->id);
+ ok($status, "Merged tickets: $msg");
+}
commit 1a39d6f96a221c2507319f932101c720a7a732c7
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Mar 25 19:00:42 2010 +0300
LoadModules method in RT::Scrip class
Thanks to Eynat Nir Mishor
diff --git a/lib/RT/Scrip_Overlay.pm b/lib/RT/Scrip_Overlay.pm
index 3310289..6c2cbd5 100755
--- a/lib/RT/Scrip_Overlay.pm
+++ b/lib/RT/Scrip_Overlay.pm
@@ -257,6 +257,19 @@ sub ConditionObj {
# }}}
+=head2 LoadModules
+
+Loads scrip's condition and action modules.
+
+=cut
+
+sub LoadModules {
+ my $self = shift;
+
+ $self->ConditionObj->LoadCondition;
+ $self->ActionObj->LoadAction;
+}
+
# {{{ sub TemplateObj
=head2 TemplateObj
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list