INN commit: trunk/control/modules (newgroup.pl)

INN Commit Russ_Allbery at isc.org
Sat Apr 4 10:40:57 UTC 2009


    Date: Saturday, April 4, 2009 @ 03:40:57
  Author: iulius
Revision: 8403

Reject newgroup control articles which are incoherent between
the announced status of the newsgroup and the moderation
flag in its description.

Modified:
  trunk/control/modules/newgroup.pl

-------------+
 newgroup.pl |   23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

Modified: newgroup.pl
===================================================================
--- newgroup.pl	2009-04-04 10:11:41 UTC (rev 8402)
+++ newgroup.pl	2009-04-04 10:40:57 UTC (rev 8403)
@@ -111,12 +111,6 @@
     if ($found) {
       ($ngname, $ngdesc) = split(/\s+/, $ngline, 2);
 
-      if ($ngdesc) {
-          $ngdesc =~ s/\s+$//;
-          $ngdesc =~ s/\s+\(moderated\)\s*$//i;
-          $ngdesc .= ' (Moderated)' if $modflag eq 'moderated';
-      }
-
       # Scan newsgroups to see the previous description, if any.
       open(NEWSGROUPS, $INN::Config::newsgroups)
           or logdie("Cannot open $INN::Config::newsgroups: $!");
@@ -159,9 +153,9 @@
     }
     if (! $errmsg) {
         if (defined &local_checkdescription) {
-            $errmsg = local_checkdescription($ngdesc);
+            $errmsg = local_checkdescription($ngdesc, $modcmd);
         } else {
-            $errmsg = checkdescription($ngdesc);
+            $errmsg = checkdescription($ngdesc, $modcmd);
         }
     }
     if ($errmsg) {
@@ -288,11 +282,20 @@
 
 # Check the description.
 sub checkdescription {
-    local $_ = shift;
+    my ($desc, $flag) = @_;
 
     # Whole-name checking.
-    return 'Empty description' if (! $_);
+    return 'Empty description' if (! $desc);
 
+    return 'Moderation status mismatch'
+        if ($desc =~ / \(Moderated\)$/) and $flag eq 'y';
+
+    return 'Moderation status mismatch'
+        if ($desc !~ / \(Moderated\)$/) and $flag eq 'm';
+
+    return 'Reserved "(Moderated)" substring used'
+        if ($desc =~ /\(Moderated\).+$/);
+
     return '';
 }
 




More information about the inn-committers mailing list