Subject: | [PATCH] Avoid warnings in SimpleGroup.pm |
This should squelch the annoying "Use of uninitialized value in string eq" warning
messages from the authorize_user routine.
--- Orig-CGI-Application-Plugin-Authorization-0.05/lib/CGI/Application/Plugin/
Authorization/Driver/SimpleGroup.pm Fri Jun 16 19:50:45 2006
+++ CGI-Application-Plugin-Authorization-0.05/lib/CGI/Application/Plugin/
Authorization/Driver/SimpleGroup.pm Fri Jul 7 10:43:47 2006
@@ -79,7 +79,18 @@
my @groups = @_;
foreach my $group (@groups) {
- return 1 if ($username eq $group);
+ # Allow undef == undef (we need this check to avoid warnings)
+ if ((not defined $username) and (not defined $group)) {
+ return 1;
+ }
+ # But don't allow if only one of the two is undef
+ # (again, we need this check to avoid warnings)
+ elsif ((not defined $username) or (not defined $group)) {
+ return 0;
+ }
+ elsif ($username eq $group) {
+ return 1;
+ }
}
return 0;
}