Skip Menu |

This queue is for tickets about the Net-Akismet CPAN distribution.

Report information
The Basics
Id: 44083
Status: new
Priority: 0/
Queue: Net-Akismet

People
Owner: Nobody in particular
Requestors: MORITZ [...] cpan.org
Cc: moritz [...] faui2k3.org
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.05
Fixed in: (no value)



CC: moritz [...] faui2k3.org
Subject: [PATCH] derive properties from CGI.pm on request
First of all thanks for the nice module, it saved me a lot of work. I found myself deriving some of the arguments from CGI.pm all over again (like the remote IP address and the user agent), so I wrote a small patch that lets you pass a CGI.pm object to check() and similar functions, which will then do that work for me. It would be nice if you could include that into the official release. Cheers, Moritz
Subject: auto_cgi.patch
--- lib/Net/Akismet.pm 2008-06-05 19:15:00.000000000 +0200 +++ lib/Net/Akismet.pm 2009-03-13 00:24:46.000000000 +0100 @@ -172,6 +172,7 @@ =back +If you pass a C<CGI.pm> object as the argument C<CGI> (as in C<use CGI; $akismet->check(CGI => CGI->new(), ...);>) then the characteristics C<USER_IP>, C<COMMENT_USER_AGENT> and C<REFERRER> will be derived from that object unless they are given explictly. =cut @@ -224,6 +225,12 @@ my $comment = shift; + if (my $cgi = $comment->{CGI}) { + $comment->{USER_IP} ||= $cgi->remote_host(), + $comment->{REFERRER} ||= $cgi->referer(), + $comment->{COMMENT_USER_AGENT} ||= $cgi->user_agent(), + } + $comment->{USER_IP} && $comment->{COMMENT_USER_AGENT} || return undef; # accomodate common misspelling