You're absolutely right. Why re-invent the wheel, right? Well, at the time I wrote the above, the
wheel in question (
CGI.pm) hadn't been written yet! ;)
I guess that just goes to show how
old this snippet is! But, I've found use for it on more that one occasion... The way I used to parse the query string used to be (and
please, please, please don't try this at home kids!) was:
sub ReadParse {
read(STDIN, $buf, $ENV{'CONTENT_LENGTH'});
@li = (split(/&/, $buf), split(/&/, $ENV{'QUERY_STRING'}));
foreach my $input (@li) {
$input =~ tr/+/ /;
$input =~ s/%(..)/pack("C", hex($1))/eg;
$input =~ s/\.\.\///g;
($name, $val) = split(/=/, $input);
$name =~ tr/A-Z/a-z/;
$in{$name}=$val;
}
}
Someone might even find THAT snippet of some interest... But as you can see from the above, the security risk of getting ../ in your file name was caught. Only God knows what other security risks could be involved nowadays!
Thanks for the words of advice.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.