[Rt-commit] rt branch, 3.8/perlcritic, updated. rt-3.8.10-65-g94bebef
Alex Vandiver
alexmv at bestpractical.com
Thu Jul 21 17:24:51 EDT 2011
The branch, 3.8/perlcritic has been updated
via 94bebef1f9ceb6804769cdaa87f07d21ab923a2c (commit)
via 3a1c1cdafc798b7e331d11460fdc704463d0d39b (commit)
from 3e34513495fa06c5b9e87823de05598b7f301b5a (commit)
Summary of changes:
bin/mason_handler.svc.in | 1 -
bin/rt.in | 9 +++++----
lib/RT/EmailParser.pm | 7 ++-----
lib/RT/Handle.pm | 2 +-
lib/RT/I18N.pm | 9 +++++----
lib/RT/Interface/REST.pm | 2 +-
lib/RT/Interface/Web.pm | 7 +++----
lib/RT/ScripAction_Overlay.pm | 12 +++++-------
lib/RT/ScripCondition_Overlay.pm | 12 +++++-------
lib/RT/Shredder/Plugin/Attachments.pm | 7 ++++---
lib/RT/Template_Overlay.pm | 3 ---
lib/RT/Tickets_Overlay_SQL.pm | 4 +++-
lib/RT/Transaction_Overlay.pm | 8 +++-----
sbin/rt-clean-sessions.in | 7 +++----
sbin/rt-email-dashboards.in | 4 +++-
sbin/rt-test-dependencies.in | 2 +-
share/html/Admin/Groups/Members.html | 2 +-
share/html/Admin/Queues/People.html | 2 +-
share/html/Admin/Tools/Shredder/index.html | 2 +-
share/html/Approvals/index.html | 2 +-
share/html/Search/Simple.html | 5 ++---
share/html/User/Delegation.html | 25 +++++++++++--------------
22 files changed, 61 insertions(+), 73 deletions(-)
- Log -----------------------------------------------------------------
commit 3a1c1cdafc798b7e331d11460fdc704463d0d39b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Jul 21 15:17:52 2011 -0400
We no longer run under taint mode; remove all spurious regexes for it
diff --git a/bin/mason_handler.svc.in b/bin/mason_handler.svc.in
index 5d9cae6..f218b31 100755
--- a/bin/mason_handler.svc.in
+++ b/bin/mason_handler.svc.in
@@ -245,7 +245,6 @@ while( my $cgi = CGI::Fast->new ) {
next;
}
- $comp = $1 if ($comp =~ /^(.*)$/);
my $web_path = RT->Config->Get('WebPath');
$comp =~ s|^\Q$web_path\E\b||i;
$comp .= "index.html" if ($comp =~ /\/$/);
diff --git a/lib/RT/EmailParser.pm b/lib/RT/EmailParser.pm
index ec91541..636acd3 100755
--- a/lib/RT/EmailParser.pm
+++ b/lib/RT/EmailParser.pm
@@ -120,11 +120,8 @@ sub SmartParseMIMEEntityFromScalar {
print $fh $args{'Message'};
close($fh);
if ( -f $temp_file ) {
-
- # We have to trust the temp file's name -- untaint it
- $temp_file =~ /(.*)/;
- my $entity = $self->ParseMIMEEntityFromFile( $1, $args{'Decode'}, $args{'Exact'} );
- unlink($1);
+ my $entity = $self->ParseMIMEEntityFromFile( $temp_file, $args{'Decode'}, $args{'Exact'} );
+ unlink($temp_file);
return $entity;
}
}
diff --git a/lib/RT/Template_Overlay.pm b/lib/RT/Template_Overlay.pm
index c0b780f..7b97f23 100755
--- a/lib/RT/Template_Overlay.pm
+++ b/lib/RT/Template_Overlay.pm
@@ -384,9 +384,6 @@ sub _ParseContent {
}
my $content = $self->SUPER::_Value('Content');
- # We need to untaint the content of the template, since we'll be working
- # with it
- $content =~ s/^(.*)$/$1/;
my $template = Text::Template->new(
TYPE => 'STRING',
SOURCE => $content
commit 94bebef1f9ceb6804769cdaa87f07d21ab923a2c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Jul 21 15:40:26 2011 -0400
Fix cases of using $1 without checking the regex -- or perlcritic thinks we do
diff --git a/bin/rt.in b/bin/rt.in
index 1ec63cd..1564980 100755
--- a/bin/rt.in
+++ b/bin/rt.in
@@ -1074,7 +1074,8 @@ sub submit {
$text =~ s/\n*$/\n/ if ($text);
# "RT/3.0.1 401 Credentials required"
- if ($status !~ m#^RT/\d+(?:\S+) (\d+) ([\w\s]+)$#) {
+ my ($code, $message) = $status =~ m#^RT/\d+(?:\S+) (\d+) ([\w\s]+)$#;
+ unless (defined $code and defined $message) {
warn "rt: Malformed RT response from $config{server}.\n";
warn "(Rerun with RTDEBUG=3 for details.)\n" if $config{debug} < 3;
exit -1;
@@ -1083,8 +1084,8 @@ sub submit {
# Our caller can pretend that the server returned a custom HTTP
# response code and message. (Doing that directly is apparently
# not sufficiently portable and uncomplicated.)
- $res->code($1);
- $res->message($2);
+ $res->code($code);
+ $res->message($message);
$res->content($text);
$session->update($res) if ($res->is_success || $res->code != 401);
@@ -1591,7 +1592,7 @@ sub expand_list {
# mix, number must be first
:defined $a->[1]? -1: 1
}
- map [ $_, (defined( /^(\d+)$/ )? $1: undef), lc($_) ],
+ map [ $_, ( /^(\d+)$/ ? $1 : undef), lc($_) ],
@elts;
}
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index ccba4b2..d0faa56 100755
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -545,7 +545,7 @@ sub GetVersionFile {
my @files = File::Glob::bsd_glob("$base_name*");
return '' unless @files;
- my %version = map { $_ =~ /\.\w+-([-\w\.]+)$/; ($1||0) => $_ } @files;
+ my %version = map { ($_ =~ /\.\w+-([-\w\.]+)$/ ? $1 : 0) => $_ } @files;
my $version;
foreach ( reverse sort {cmp_version($a,$b)} keys %version ) {
if ( cmp_version( $db_version, $_ ) >= 0 ) {
diff --git a/lib/RT/I18N.pm b/lib/RT/I18N.pm
index 42263eb..7cc6cfe 100755
--- a/lib/RT/I18N.pm
+++ b/lib/RT/I18N.pm
@@ -101,15 +101,16 @@ sub Init {
# Load language-specific functions
foreach my $file ( File::Glob::bsd_glob(substr(__FILE__, 0, -3) . "/*.pm") ) {
- unless ( $file =~ /^([-\w\s\.\/\\~:]+)$/ ) {
+ my ($clean) = $file =~ /^([-\w\s\.\/\\~:]+)$/;
+
+ unless ( $clean ) {
warn("$file is tainted. not loading");
next;
}
- $file = $1;
- my ($lang) = ($file =~ /([^\\\/]+?)\.pm$/);
+ my ($lang) = ($clean =~ /([^\\\/]+?)\.pm$/);
next unless grep $_ eq '*' || $_ eq $lang, @lang;
- require $file;
+ require $clean;
}
my %import;
diff --git a/lib/RT/Interface/REST.pm b/lib/RT/Interface/REST.pm
index 47c8de2..d26a763 100755
--- a/lib/RT/Interface/REST.pm
+++ b/lib/RT/Interface/REST.pm
@@ -110,7 +110,7 @@ sub expand_list {
# mix, number must be first
:defined $a->[1]? -1: 1
}
- map [ $_, (defined( /^(\d+)$/ )? $1: undef), lc($_) ],
+ map [ $_, ( /^(\d+)$/ ? $1 : undef), lc($_) ],
@elts;
}
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 29ce1c2..47c7b54 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1552,7 +1552,7 @@ sub ProcessACLChanges {
my @results;
foreach my $arg ( keys %$ARGSref ) {
- next unless ( $arg =~ /^(GrantRight|RevokeRight)-(\d+)-(.+?)-(\d+)$/ );
+ $arg =~ /^(GrantRight|RevokeRight)-(\d+)-(.+?)-(\d+)$/ or next;
my ( $method, $principal_id, $object_type, $object_id ) = ( $1, $2, $3, $4 );
@@ -2290,9 +2290,8 @@ container object and the search id.
sub _parse_saved_search {
my $spec = shift;
return unless $spec;
- if ( $spec !~ /^(.*?)-(\d+)-SavedSearch-(\d+)$/ ) {
- return;
- }
+ $spec =~ /^(.*?)-(\d+)-SavedSearch-(\d+)$/ or return;
+
my $obj_type = $1;
my $obj_id = $2;
my $search_id = $3;
diff --git a/lib/RT/ScripAction_Overlay.pm b/lib/RT/ScripAction_Overlay.pm
index 9ea6772..3fea295 100755
--- a/lib/RT/ScripAction_Overlay.pm
+++ b/lib/RT/ScripAction_Overlay.pm
@@ -164,14 +164,12 @@ sub LoadAction {
@_ );
$self->{_TicketObj} = $args{TicketObj};
-
- #TODO: Put this in an eval
- $self->ExecModule =~ /^(\w+)$/;
- my $module = $1;
- my $type = "RT::Action::". $module;
-
+
+ $self->ExecModule =~ /^(\w+)$/ or die "Invalid scrip action: ".$self->ExecModule;
+ my $type = "RT::Action::" . $1;
+
eval "require $type" || die "Require of $type failed.\n$@\n";
-
+
$self->{'Action'} = $type->new ( Argument => $self->Argument,
CurrentUser => $self->CurrentUser,
ScripActionObj => $self,
diff --git a/lib/RT/ScripCondition_Overlay.pm b/lib/RT/ScripCondition_Overlay.pm
index ff22ad1..ecb7735 100755
--- a/lib/RT/ScripCondition_Overlay.pm
+++ b/lib/RT/ScripCondition_Overlay.pm
@@ -167,14 +167,12 @@ sub LoadCondition {
my %args = ( TransactionObj => undef,
TicketObj => undef,
@_ );
-
- #TODO: Put this in an eval
- $self->ExecModule =~ /^(\w+)$/;
- my $module = $1;
- my $type = "RT::Condition::". $module;
-
+
+ $self->ExecModule =~ /^(\w+)$/ or die "Invalid scrip condition: ".$self->ExecModule;
+ my $type = "RT::Condition::" . $1;
+
eval "require $type" || die "Require of $type failed.\n$@\n";
-
+
$self->{'Condition'} = $type->new ( 'ScripConditionObj' => $self,
'TicketObj' => $args{'TicketObj'},
'ScripObj' => $args{'ScripObj'},
diff --git a/lib/RT/Shredder/Plugin/Attachments.pm b/lib/RT/Shredder/Plugin/Attachments.pm
index 3cbadea..ed898cb 100644
--- a/lib/RT/Shredder/Plugin/Attachments.pm
+++ b/lib/RT/Shredder/Plugin/Attachments.pm
@@ -112,9 +112,10 @@ sub Run
}
if( $self->{'opt'}{'longer'} ) {
my $size = $self->{'opt'}{'longer'};
- $size =~ s/([mk])//i;
- $size *= 1024 if $1 && lc $1 eq 'k';
- $size *= 1024*1024 if $1 && lc $1 eq 'm';
+ if ($size =~ s/([km])//i) {
+ $size *= 1024 if lc $1 eq 'k';
+ $size *= 1024*1024 if lc $1 eq 'm';
+ }
push @conditions, "( LENGTH(Content) > ? )";
push @values, $size;
}
diff --git a/lib/RT/Tickets_Overlay_SQL.pm b/lib/RT/Tickets_Overlay_SQL.pm
index b6ef5e5..4973fe0 100755
--- a/lib/RT/Tickets_Overlay_SQL.pm
+++ b/lib/RT/Tickets_Overlay_SQL.pm
@@ -188,7 +188,9 @@ sub _parser {
# key has dot then it's compound variant and we have subkey
my $subkey = '';
- ($key, $subkey) = ($1, $2) if $key =~ /^([^\.]+)\.(.+)$/;
+ if ( $key =~ /^([^\.]+)\.(.+)$/ ) {
+ ($key, $subkey) = ($1, $2);
+ }
# normalize key and get class (type)
my $class;
diff --git a/lib/RT/Transaction_Overlay.pm b/lib/RT/Transaction_Overlay.pm
index ea6461d..223b229 100755
--- a/lib/RT/Transaction_Overlay.pm
+++ b/lib/RT/Transaction_Overlay.pm
@@ -1158,11 +1158,9 @@ sub UpdateCustomFields {
}
foreach my $arg ( keys %$args ) {
- next
- unless ( $arg =~
- /^(?:Object-RT::Transaction--)?CustomField-(\d+)/ );
- next if $arg =~ /-Magic$/;
- my $cfid = $1;
+ next if $arg =~ /-Magic$/;
+ my ($cfid) = $arg =~ /^(?:Object-RT::Transaction--)?CustomField-(\d+)/;
+ next unless defined $cfid;
my $values = $args->{$arg};
foreach
my $value ( (ref($values) eq 'ARRAY' ) ? @$values : $values )
diff --git a/sbin/rt-clean-sessions.in b/sbin/rt-clean-sessions.in
index 9ededb2..f5e9240 100644
--- a/sbin/rt-clean-sessions.in
+++ b/sbin/rt-clean-sessions.in
@@ -86,10 +86,9 @@ if ( $opt{help} ) {
if( $opt{'older'} ) {
- unless( $opt{'older'} =~ /^\s*([0-9]+)\s*(H|D|M|Y)?$/i ) {
- print STDERR "wrong format of the 'older' argumnet\n";
- exit(1);
- }
+ $opt{'older'} =~ /^\s*([0-9]+)\s*(H|D|M|Y)?$/i
+ or die "wrong format of the 'older' argument\n";
+
my ($num,$unit) = ($1, uc($2 ||'D'));
my %factor = ( H => 60*60 );
$factor{'D'} = $factor{'H'}*24;
diff --git a/sbin/rt-email-dashboards.in b/sbin/rt-email-dashboards.in
index fccf339..85957c5 100644
--- a/sbin/rt-email-dashboards.in
+++ b/sbin/rt-email-dashboards.in
@@ -464,7 +464,9 @@ sub get_resource {
$content = run_component($path, %args);
# guess at the filename from the component name
- $filename = $1 if $path =~ m{^.*/(.*?)$};
+ if ( $path =~ m{^.*/(.*?)$} ) {
+ $filename = $1;
+ }
# the rest of this was taken from Email::MIME::CreateHTML::Resolver::LWP
($mimetype, $encoding) = MIME::Types::by_suffix($filename);
diff --git a/sbin/rt-test-dependencies.in b/sbin/rt-test-dependencies.in
index 7825b5a..c638bf6 100755
--- a/sbin/rt-test-dependencies.in
+++ b/sbin/rt-test-dependencies.in
@@ -395,7 +395,7 @@ check_users();
my %Missing_By_Type = ();
foreach my $type (sort grep $args{$_}, keys %args) {
- next unless ($type =~ /^with-(.*?)$/);
+ $type =~ /^with-(.*?)$/ or next;
$type = $1;
section("$type dependencies");
diff --git a/share/html/Admin/Groups/Members.html b/share/html/Admin/Groups/Members.html
index b1bfe93..f8245e6 100755
--- a/share/html/Admin/Groups/Members.html
+++ b/share/html/Admin/Groups/Members.html
@@ -123,7 +123,7 @@ my (@results);
# XXX: safe member id in value instead of name
foreach my $key (keys %ARGS) {
- next unless $key =~ /^DeleteMember-(\d+)$/;
+ $key =~ /^DeleteMember-(\d+)$/ or next;
my ($val,$msg) = $Group->DeleteMember($1);
push (@results, $msg);
diff --git a/share/html/Admin/Queues/People.html b/share/html/Admin/Queues/People.html
index 61b85f6..0a8ac1b 100755
--- a/share/html/Admin/Queues/People.html
+++ b/share/html/Admin/Queues/People.html
@@ -152,7 +152,7 @@ unless ($OnlySearchForPeople or $OnlySearchForGroup) {
foreach my $key (keys %ARGS) {
my $id = $QueueObj->Id;
- if (($key =~ /^Queue-$id-DeleteWatcher-Type-(.*?)-Principal-(\d*)$/)) {;
+ if ($key =~ /^Queue-$id-DeleteWatcher-Type-(.*?)-Principal-(\d*)$/) {
my ($code, $msg) = $QueueObj->DeleteWatcher(Type => $1,
PrincipalId => $2);
push @results, $msg;
diff --git a/share/html/Admin/Tools/Shredder/index.html b/share/html/Admin/Tools/Shredder/index.html
index acb956d..29a3ce2 100644
--- a/share/html/Admin/Tools/Shredder/index.html
+++ b/share/html/Admin/Tools/Shredder/index.html
@@ -107,7 +107,7 @@ if( $Plugin ) { { # use additional block({}) to effectively exit block on errors
my %args;
foreach my $k( keys %ARGS ) {
- next unless $k =~ /^\Q$Plugin\E:(.*)$/;
+ $k =~ /^\Q$Plugin\E:(.*)$/ or next;
$args{ $1 } = $ARGS{$k};
}
( $status, $msg ) = $plugin_obj->HasSupportForArgs( keys %args );
diff --git a/share/html/Approvals/index.html b/share/html/Approvals/index.html
index cfd5ab4..04f0c4e 100755
--- a/share/html/Approvals/index.html
+++ b/share/html/Approvals/index.html
@@ -58,7 +58,7 @@
my (@actions);
foreach my $arg ( keys %ARGS ) {
- next unless ( $arg =~ /Approval-(\d+)-Action/ );
+ $arg =~ /Approval-(\d+)-Action/ or next;
my ( $notesval, $notesmsg );
diff --git a/share/html/Search/Simple.html b/share/html/Search/Simple.html
index 08945e5..3673867 100644
--- a/share/html/Search/Simple.html
+++ b/share/html/Search/Simple.html
@@ -81,9 +81,8 @@ if ($q) {
my $tickets = RT::Tickets->new( $session{'CurrentUser'} );
$m->callback( %ARGS, query => \$q, CallbackName => 'ModifyQuery' );
- if ($q =~ /^#?(\d+)$/) {
- RT::Interface::Web::Redirect(RT->Config->Get('WebURL')."Ticket/Display.html?id=".$1);
- }
+ RT::Interface::Web::Redirect(RT->Config->Get('WebURL')."Ticket/Display.html?id=".$q)
+ if $q =~ s/^#?(\d+)$/$1/;
my %args = (
Argument => $q,
diff --git a/share/html/User/Delegation.html b/share/html/User/Delegation.html
index 3358935..13b3e4a 100755
--- a/share/html/User/Delegation.html
+++ b/share/html/User/Delegation.html
@@ -63,26 +63,23 @@
my (@results);
foreach my $arg (keys %ARGS) {
- next unless ($arg =~ /^Delegate-Existing-ACE-(\d+)-to-(\d+)-as-(\d+)$/);
- my $parent = $1;
- my $principal = $2;
- my $delegation = $3;
- unless ($ARGS{"Delegate-ACE-$1-to-$2"}) {
- my $ace_to_del = RT::ACE->new($session{'CurrentUser'});
- $ace_to_del->Load($delegation);
- my ($delval, $delmsg) = $ace_to_del->Delete();
- push (@results, $delmsg);
- }
+ my ($parent, $principal, $delegation) =
+ $arg =~ /^Delegate-Existing-ACE-(\d+)-to-(\d+)-as-(\d+)$/ or next;
+ unless ($ARGS{"Delegate-ACE-$parent-to-$principal"}) {
+ my $ace_to_del = RT::ACE->new($session{'CurrentUser'});
+ $ace_to_del->Load($delegation);
+ my ($delval, $delmsg) = $ace_to_del->Delete();
+ push (@results, $delmsg);
+ }
}
foreach my $arg (keys %ARGS) {
- next unless ($arg =~ /^Delegate-ACE-(\d+)-to-(\d+)$/);
- my $parent = $1;
- my $principal = $2;
+ my ($parent, $principal) =
+ $arg =~ /^Delegate-ACE-(\d+)-to-(\d+)$/ or next;
# if we already delegate it, we just don't care
next if (grep /^Delegate-Existing-ACE-$parent-to-$principal-/, keys %ARGS);
my $ace = RT::ACE->new($session{'CurrentUser'});
- $ace->Load($1);
+ $ace->Load($parent);
unless ($ace->Id) {
push (@results, loc('Right not found'));
next;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list