My original post may not have been clear.
Logic I'm shooting for goes something like this:
- untaint via word-characters only
- if /index.pl?page=illegal_character *or* if /index.pl?page=nonexistant_urlist
- if /index.pl?page=valid_urlist
- if URL does *not* include /index.pl?page=something
With answers from
yourself,
Ovid,
davorg, and
a, I expect I can come up with code that will work. Thanks and ++ to all 8^)
Update: Hours past my bedtime and I've got what appears to work. Round o' ++, my treat! 8^D
# (must precede untaint)
# Set query param to site home if url is:
# / /index.pl /index.pl? /index.pl?page
param('page','home') if ! defined param('page');
# Untaint query param
if ($query = param('page') =~ /^(\w+)$/) {
$urlist = $1;
}
else {
$urlist = 'error';
}
# Build array of urlist files
opendir DIR, "$confdir/";
my @files = grep {
$_ ne '.' &&
$_ ne '..' &&
}
readdir DIR;
closedir DIR;
unless (grep{$_ eq $urlist} @files) {
$urlist = 'error';
}
cheers,
Don
striving for Perl Adept
(it's pronounced "why-bick")
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.