Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Should I just forget the pattern match and just test that there aren't any funky characters? What all should I be allowing? Does anyone have some suggestions for me?sub untaintFile{ my $text=$_[0]; if (defined $text && $text ne ''){ if ($text =~ /^(\w\:([\\\/][\w\s\]+[\w\s\-\.\']*\.?[\w +\s]*)*)$/ || $text =~ /^(\\([\\\/][\w\s\]+[\w\s\-\.\']*\.?[\w\s +]*)*)$/ ) { $text = "$1"; } else { ...code for sending me an email... $text = ""; } } return $text; }
I'm not a unix or security expert by any stretch, so i'm not exactly sure what I should consider 'safe'. Everything I've found so far on validating input is very vague and non-specific, just that good practice is to have a whitelist and not allow anything except your whitelist.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Testing file input validity in FF
by almut (Canon) on Feb 17, 2009 at 20:38 UTC | |
by ksublondie (Friar) on Feb 17, 2009 at 22:01 UTC | |
by Anonymous Monk on Feb 18, 2009 at 08:28 UTC | |
by ksublondie (Friar) on Feb 18, 2009 at 17:55 UTC | |
by Anonymous Monk on Feb 20, 2009 at 07:33 UTC | |
| |
by scorpio17 (Canon) on Feb 18, 2009 at 15:00 UTC | |
by ksublondie (Friar) on Feb 19, 2009 at 20:30 UTC | |
|
Re: Testing file input validity in FF
by ksublondie (Friar) on Feb 17, 2009 at 19:53 UTC |