[vhffs-dev] [1322] listengine is a bit more case-insensitive, may help people who change their From

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1322
Author:   gradator
Date:     2009-01-11 18:04:48 +0100 (Sun, 11 Jan 2009)

Log Message:
-----------
listengine is a bit more case-insensitive, may help people who change their From

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Services/MailingList.pm
    trunk/vhffs-listengine/src/listengine.pl


Modified: trunk/vhffs-api/src/Vhffs/Services/MailingList.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/MailingList.pm	2008-12-24 16:20:33 UTC (rev 1321)
+++ trunk/vhffs-api/src/Vhffs/Services/MailingList.pm	2009-01-11 17:04:48 UTC (rev 1322)
@@ -221,7 +221,7 @@
 sub add_sub
 {
     my $self = shift;
-    my $subscriber = shift;
+    my $subscriber = lc shift;
     my $right = shift;
 
     return -1 unless( Vhffs::Functions::valid_mail( $subscriber ) );
@@ -252,7 +252,7 @@
 sub add_sub_with_reply
 {
     my $self = shift;
-    my $subscriber = shift;
+    my $subscriber = lc shift;
 
     return undef unless( Vhffs::Functions::valid_mail( $subscriber ) );
     return undef if( $subscriber =~ /.*<.*/ );

Modified: trunk/vhffs-listengine/src/listengine.pl
===================================================================
--- trunk/vhffs-listengine/src/listengine.pl	2008-12-24 16:20:33 UTC (rev 1321)
+++ trunk/vhffs-listengine/src/listengine.pl	2009-01-11 17:04:48 UTC (rev 1322)
@@ -143,13 +143,15 @@
 		unlink $errorf if ( -f $errorf  &&  ! -s $errorf );
 	}
 	else {
+		my $from = lc $mail->get('From');
+
 		foreach my $adr (@tos)
 		{
 			my $smtp = Net::SMTP->new( $SMTP_SERVER,
 				Hello => $DOMAIN,
 			);
 
-			$smtp->mail( $mail->get('From') );
+			$smtp->mail( $from );
 			$smtp->to( $adr );
 			$smtp->data( $mail->as_string );
 			$smtp->quit;
@@ -195,6 +197,7 @@
     my $email;
     my ( $message_id  ) =  ($mail->get( 'Message-Id' ) =~ /<(.+)>/);
     my ( $from ) = ( $mail->get('From') =~ /(([\+\.a-zA-Z_\-0-9^\s]+)@([\.a-zA-Z_\-0-9^\s]+)\.(\w+))/);
+    $from = lc $from;
     my $directory = get_moderation_dir( $list );
     my $subject = $mail->get('Subject');
 
@@ -672,6 +675,7 @@
 	exit -1 if( ! defined $list );
     
 	my ( $from ) = ( $mail->get('From') =~ /(([\+\.a-zA-Z_\-0-9^\s]+)@([a\.-zA-Z_\-0-9^\s]+)\.(\w+))/);
+        $from = lc $from;
 	my $subject = $mail->get('Subject');
 	my $subs = $list->get_members;
     
@@ -784,7 +788,7 @@
 		$mail = fetch_mail_from_file( $complete );
 		next if( ! defined $mail );
 		
-		push( @result , "Sender: " . $mail->get('From:') );
+		push( @result , "Sender: " . lc $mail->get('From:') );
 		push( @result , "Subject: " . $mail->get('Subject:') );
 		push( @result , "Id in listengine: " . $file );
 		push( @result , "\n\n");
@@ -812,6 +816,7 @@
     my $list = shift;
 
     my ( $from ) = ( $mail->get('From') =~ /(([\+\.a-zA-Z_\-0-9^\s]+)@([\.a-zA-Z_\-0-9^\s]+)\.(\w+))/);
+    $from = lc $from;
     my $subject = $mail->get('Subject');
     my $action;
     my $subscriber;
@@ -832,7 +837,7 @@
 
 
 
-    if( $subject =~ /^help$/ )
+    if( $subject =~ /^help$/i )
     {
 		$email = Mail::Internet->new( [ <> ],
 			     Body => Vhffs::Listengine::mail_generate_help
@@ -843,15 +848,15 @@
     	$email->replace('Date' , gmtime()." +00");
 		sendmail( $email , $from );
     }
-    elsif( $subject =~ /^subscribe$/ )
+    elsif( $subject =~ /^subscribe$/i )
     {
 		subscribe_to_list( $list , $from );
     }
-    elsif( $subject =~ /^unsubscribe$/ )
+    elsif( $subject =~ /^unsubscribe$/i )
     {
 		unsubscribe_to_list( $list , $from );
     }
-    elsif( ( $lang ) = $subject =~ /^lang\s([a-zA-Z\_\-]+)$/ )
+    elsif( ( $lang ) = $subject =~ /^lang\s([a-zA-Z\_\-]+)$/i )
     {
 	#Try to change the language for this subscriber on whole listengine subsystem
 	unless( Vhffs::Services::MailingList::set_language_for_sub( $vhffs , $from , $lang ) )
@@ -877,7 +882,7 @@
 	    sendmail( $email , $from );
 	}
     }
-    elsif( ( $temp ) = $subject =~ /[.\s]*moderate\s([a-zA-Z0-9\s]+)$/ )
+    elsif( ( $temp ) = $subject =~ /[.\s]*moderate\s([a-zA-Z0-9\s]+)$/i )
     {
 	#To moderate messages, users must be at least ADMIN
 	#So, we check this NOW
@@ -894,7 +899,7 @@
 	    sendmail( $email , $from );
 	   
 	}
-	elsif( ( $hash ) = $temp =~ /accept\s([a-zA-Z0-9]+)$/ )
+	elsif( ( $hash ) = $temp =~ /accept\s([a-zA-Z0-9]+)$/i )
 	{
 
 	    if( validate_message( $list , $hash , $from ) < 0 )
@@ -921,7 +926,7 @@
 	    }
 	 
 	}
-	elsif( ( $hash ) = $temp =~ /refuse\s([a-zA-Z0-9]+)$/ )
+	elsif( ( $hash ) = $temp =~ /refuse\s([a-zA-Z0-9]+)$/i )
 	{
 	    #Here, we refuse the message
 	    if( refuse_message( $list , $hash , $from ) < 0 )
@@ -949,7 +954,7 @@
 	    }
 	    return;
 	}
-	elsif( $temp =~ /^list$/ )
+	elsif( $temp =~ /^list$/i )
 	{
 	    $email = Mail::Internet->new( [ <> ],
 					 Body => list_msg_to_moderate( $list )
@@ -961,7 +966,7 @@
 	    sendmail( $email , $from );
 	    return;
 	}
-	elsif( $temp =~ /^[a-zA-Z0-9]+$/ )
+	elsif( $temp =~ /^[a-zA-Z0-9]+$/i )
 	{
 	    if( validate_message( $list , $temp , $from ) < 0 )
 	    {
@@ -1102,6 +1107,7 @@
 {
     my $mail = shift;
     my ( $from ) = ( $mail->get('From') =~ /(([\+\.a-zA-Z_\-0-9^\s]+)@([\.a-zA-Z_\-0-9^\s]+)\.(\w+))/);
+    $from = lc $from;
 
     my $lang = Vhffs::Services::MailingList::get_language_for_sub( $vhffs , $from );
     if( defined $lang )
@@ -1123,7 +1129,7 @@
         my $list = shift;
         my $mail = shift;
 
-        my $from = $mail->get('From');
+        my $from = lc $mail->get('From');
 
         my $temp = $list->get_localpart."-request\@".$list->get_domain;
         exit( 0 ) if( $from eq $list->get_listname);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/