Skip to content

Commit

Permalink
new(): Use Scalar::Util to verify it's an object
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Oct 25, 2024
1 parent 8d9cccc commit 5ec30de
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Revision history for CGI-Info
0.85
Send back HTTP code 422 when argument fails "allow"
Added come comments and small optimisations
new(): Use Scalar::Util to verify it's an object

0.84 Fri Oct 18 08:21:05 EDT 2024
Intercept SQL Injection
Expand Down
3 changes: 2 additions & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ WriteMakefile(
'Tie::Filehandle::Preempt::Stdin' => 0,
}, PREREQ_PM => {
'Carp' => 0,
'Scalar::Util' => 0,
'URI::Heuristic' => 0,
# 'Sub::Private' => 0,
'Sys::Hostname' => 0,
Expand All @@ -66,7 +67,7 @@ WriteMakefile(
# 'String::EscapeCage' => 0.02,
'Class::Autouse' => 0,
'namespace::clean' => 0,
'Sys::Path' => 0,
'Sys::Path' => 0
}, dist => $dist,
clean => { FILES => 'CGI-Info-*' },
# META_ADD => {
Expand Down
5 changes: 3 additions & 2 deletions lib/CGI/Info.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use warnings;
use strict;
use Carp;
use File::Spec;
use Scalar::Util;
use Socket; # For AF_INET
use 5.008;
use Log::Any qw($log);
Expand Down Expand Up @@ -101,7 +102,7 @@ sub new

# FIXME: this only works when no arguments are given
$class = __PACKAGE__;
} elsif(ref($class)) {
} elsif(Scalar::Util::blessed($class)) {
# If $class is an object, clone it with new arguments
return bless { %{$class}, %args }, ref($class);
}
Expand Down Expand Up @@ -918,7 +919,7 @@ sub _get_params
my $num_args = scalar @_;

# Populate %rc based on the number and type of arguments
if($num_args == 1 && defined $default) {
if(($num_args == 1) && (defined $default)) {
%rc = ($default => shift);
} elsif(($num_args % 2) == 0) {
%rc = @_;
Expand Down

0 comments on commit 5ec30de

Please sign in to comment.