On Jun 5, 2007, at 12:56 PM, John ORourke wrote:
my $q=Apache2::Request->new($r);
my $known_to_be_utf8 = $q->param('test'); # form post doesn't
give charset, none assumed
slightly off topic, my suggestion on implementation would be along
the lines of this:
package Context();
sub new(){}
sub getPost{}
sub getGet{}
sub getGetPost{}
1;
where you have a Context class. instead of calling $q->param ,you
call $ctx->getPost
Context does two things:
a- it encapsulates all of the charset crap, so you only write it once.
b- it gives you a uniform access to a few apache::request and cgi
functions. this way you can switch between the two as needed.
i switched to that a few weeks ago. i think randy has a cpan module
that is similar.
its a damn lifesaver though. i took a negligible hit in wrapping all
my get/post in that, but all of my data santization routines are
right there in that module. (strip whitespace, strip charsets i
don't want, etc )
( i actually double wrapped it -- class: Context gives me a wrapper,
class MyApp::Context subclasses Context and overloads the getpost
with custom sanitization routines per app ).