Skip to content

Commit

Permalink
Better error message when discarding argument
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Jan 28, 2025
1 parent 108d58e commit ca6e345
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Revision history for CGI-Info

0.89
0.89 Tue Jan 14 15:45:16 EST 2025
Fix http://www.cpantesters.org/cpan/report/048c5109-6c77-1014-8029-e79fc7de0390

0.88 Mon Jan 13 09:33:24 EST 2025
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CGI-Info Version 0.88
CGI-Info Version 0.89

INSTALLATION

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
CGI-Info
========

-[![Travis Status](https://travis-ci.org/nigelhorne/CGI-Info.svg?branch=master)](https://travis-ci.org/nigelhorne/CGI-Info)
-[![Appveyor Status](https://ci.appveyor.com/api/projects/status/1t1yhvagx00c2qi8?svg=true)](https://ci.appveyor.com/project/nigelhorne/cgi-info)
[![CircleCI](https://dl.circleci.com/status-badge/img/circleci/8CE7w65gte4YmSREC2GBgW/THucjGauwLPtHu1MMAueHj/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/circleci/8CE7w65gte4YmSREC2GBgW/THucjGauwLPtHu1MMAueHj/tree/main)
Expand All @@ -15,7 +18,7 @@ CGI::Info gets information about the system that a CGI script is running on.

# VERSION

Version 0.88
Version 0.89

# SYNOPSIS

Expand Down
11 changes: 7 additions & 4 deletions lib/CGI/Info.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ CGI::Info gets information about the system that a CGI script is running on.
=head1 VERSION
Version 0.88
Version 0.89
=cut

our $VERSION = '0.88';
our $VERSION = '0.89';

=head1 SYNOPSIS
Expand Down Expand Up @@ -96,10 +96,13 @@ sub new
# Handle hash or hashref arguments
my %args;
if((@_ == 1) && (ref $_[0] eq 'HASH')) {
# If the first argument is a hash reference, dereference it
%args = %{$_[0]};
} elsif((@_ % 2) == 0) {
# If there is an even number of arguments, treat them as key-value pairs
%args = @_;
} else {
# If there is an odd number of arguments, treat it as an error
carp(__PACKAGE__, ': Invalid arguments passed to new()');
return;
}
Expand Down Expand Up @@ -745,15 +748,15 @@ sub params {
if($self->{allow}) {
# Is this a permitted argument?
if(!exists($self->{allow}->{$key})) {
$self->_info("discard $key");
$self->_info("Discard unallowed argument '$key'");
$self->status(422);
next;
}

# Do we allow any value, or must it be validated?
if(defined($self->{allow}->{$key})) {
if($value !~ $self->{allow}->{$key}) {
$self->_info("block $key = $value");
$self->_info("Block $key = $value");
$self->status(422);
next;
}
Expand Down
4 changes: 2 additions & 2 deletions t/gv.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use strict;
use warnings;

use Test::DescribeMe qw(author);
use Test::More;
use Test::Most;
use Test::Needs 'Test::GreaterVersion';

Test::GreaterVersion::has_greater_version_than_cpan('CGI::Info');
Test::GreaterVersion::has_greater_version_than_cpan('LWP::UserAgent::Throttled');

done_testing();
1 change: 0 additions & 1 deletion t/strict.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use strict;
use warnings;

use Test::DescribeMe qw(author);
use Test::Most;
use Test::Needs 'Test::Strict';

Test::Strict->import();
Expand Down

0 comments on commit ca6e345

Please sign in to comment.