[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.7-128-g39ebf0a

Ruslan Zakirov ruz at bestpractical.com
Tue Feb 2 15:43:32 EST 2010


The branch, 3.8-trunk has been updated
       via  39ebf0ac5a82ea6a3b9f689db074074d962484ca (commit)
       via  0783495c45a8f5b608f1b5ff96c0b6205f8d9f52 (commit)
       via  bbc4db537e908f20083b76e15eaf47f2344d1e4d (commit)
      from  4d732b981c03849b1a187b214b0391ee8e1070de (commit)

Summary of changes:
 etc/RT_Config.pm.in           |    2 +-
 lib/RT/Config.pm              |   34 ++++++++++++++++++++++++++++++++++
 lib/RT/User_Overlay.pm        |    2 +-
 share/html/Ticket/Create.html |   19 +++++++++++++++++++
 share/html/Ticket/Update.html |   19 +++++++++++++++++++
 5 files changed, 74 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit bbc4db537e908f20083b76e15eaf47f2344d1e4d
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Feb 2 18:47:01 2010 +0300

    yell at people and autogen RTAddressRegexp

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 5500356..3468af8 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -286,7 +286,7 @@ avoid sending mail to itself.  It will also hide RT addresses from the list of
 
 =cut
 
-Set($RTAddressRegexp , '^rt\@example.com$');
+Set($RTAddressRegexp , undef);
 
 =item C<$CanonicalizeEmailAddressMatch>, C<$CanonicalizeEmailAddressReplace>
 
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 6fc1b89..b652d3e 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -333,6 +333,40 @@ 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 may result in big mail loops.'
+                .' Going to generate value for you, but generating value takes'
+                .' time and only a few queues are accounted. So this slow downs'
+                .' server restarts and command line utilities, as well dont'
+                .' protect you from loops if you have many queues'
+            );
+
+            my @emails = (
+                $self->Get('CorrespondAddress'),
+                $self->Get('CommentAddress'),
+            );
+            my $queues = RT::Queues->new( $RT::SystemUser );
+            $queues->UnLimit;
+            $queues->RowsPerPage(100);
+            while ( my $queue = $queues->Next ) {
+                push @emails, $queue->CorrespondAddress, $queue->CommentAddress;
+            }
+
+            my %seen;
+            my $re = join '|', map "\Q$_\E",
+                grep defined && length && !$seen{ lc $_ }++,
+                @emails;
+            $self->Set( qr/$re/ );
+        },
+    },
     # User overridable mail options
     EmailFrequency => {
         Section         => 'Mail',                                     #loc

commit 0783495c45a8f5b608f1b5ff96c0b6205f8d9f52
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Feb 2 23:30:20 2010 +0300

    crypt dies when first value is UTF-8 string

diff --git a/lib/RT/User_Overlay.pm b/lib/RT/User_Overlay.pm
index db3964c..8a41639 100755
--- a/lib/RT/User_Overlay.pm
+++ b/lib/RT/User_Overlay.pm
@@ -1034,7 +1034,7 @@ sub IsPassword {
     }
 
     #  if it's a historical password we say ok.
-    if ($self->__Value('Password') eq crypt($value, $self->__Value('Password'))
+    if ($self->__Value('Password') eq crypt(encode_utf8($value), $self->__Value('Password'))
         or $self->_GeneratePasswordBase64($value) eq $self->__Value('Password'))
     {
         # ...but upgrade the legacy password inplace.

commit 39ebf0ac5a82ea6a3b9f689db074074d962484ca
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Feb 2 23:41:40 2010 +0300

    check emails for RT's addresses on Create and Update

diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index 28b6556..941df1e 100755
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -392,6 +392,25 @@ if ( !exists $ARGS{'AddMoreAttach'} && ($ARGS{'id'}||'') eq 'new' ) {
     $checks_failure = 1 unless $status;
 }
 
+# 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;
+
+            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;
+        }
+        $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
+    }
+}
+
 my $skip_create = 0;
 $m->callback( CallbackName => 'BeforeCreate', ARGSRef => \%ARGS, skip_create => \$skip_create, 
               checks_failure => $checks_failure, results => \@results );
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index c64e86c..58e1812 100755
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -259,6 +259,25 @@ if ( $ARGS{'SubmitTicket'} ) {
     $checks_failure = 1 unless $status;
 }
 
+# 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;
+
+            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;
+        }
+        $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
+    }
+}
+
 if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {
     $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
     return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);

-----------------------------------------------------------------------


More information about the Rt-commit mailing list