Merge branch 'thh-checkinput' into next
authorThomas Hochstein <thh@inter.net>
Mon, 2 Sep 2013 10:59:45 +0000 (12:59 +0200)
committerThomas Hochstein <thh@inter.net>
Mon, 2 Sep 2013 10:59:45 +0000 (12:59 +0200)
* thh-checkinput:
  Check for invalid newsgroup names.

1  2 
groupstats.pl

diff --combined groupstats.pl
@@@ -1,4 -1,4 +1,4 @@@
 -#! /usr/bin/perl -W
 +#! /usr/bin/perl
  #
  # groupstats.pl
  #
@@@ -18,7 -18,6 +18,7 @@@ BEGIN 
    push(@INC, dirname($0));
  }
  use strict;
 +use warnings;
  
  use NewsStats qw(:DEFAULT :TimePeriods :Output :SQLHelper ReadGroupList);
  
@@@ -100,8 -99,13 +100,13 @@@ my ($CaptionPeriod,$SQLWherePeriod) = &
           "please use 'YYYY-MM', 'YYYY-MM:YYYY-MM' or 'ALL'!") if !$CaptionPeriod;
  # get list of newsgroups and set expression for SQL 'WHERE' clause
  # with placeholders as well as a list of newsgroup to bind to them
- my ($SQLWhereNewsgroups,@SQLBindNewsgroups) = &SQLGroupList($OptNewsgroups)
-   if $OptNewsgroups;;
+ my ($SQLWhereNewsgroups,@SQLBindNewsgroups);
+ if ($OptNewsgroups) {
+   ($SQLWhereNewsgroups,@SQLBindNewsgroups) = &SQLGroupList($OptNewsgroups);
+   # bail out if --newsgroups is invalid
+   &Bleat(2,"--newsgroups option has an invalid format!")
+     if !$SQLWhereNewsgroups;
+ }
  
  ### build SQL WHERE clause (and HAVING clause, if needed)
  my ($SQLWhereClause,$SQLHavingClause);
@@@ -194,8 -198,8 +199,8 @@@ if ($OptBoundType and $OptBoundType ne 
  $DBQuery = $DBHandle->prepare(sprintf('SELECT %s FROM %s.%s %s %s %s',
                                        $SQLSelect,
                                        $Conf{'DBDatabase'},$Conf{'DBTableGrps'},
-                                       $SQLWhereClause,$SQLGroupClause,$
-                                       SQLOrderClause));
+                                       $SQLWhereClause,$SQLGroupClause,
+                                       $SQLOrderClause));
  
  # execute query
  $DBQuery->execute(@SQLBindNewsgroups)
This page took 0.012783 seconds and 4 git commands to generate.