in reply to escaping filenames taken in via user input
my $filename = take_user_input(); $filename =~ s/\W//g; # allows only alphanumerics and the underscore $filename = $filename . ".txt"; # forces them to only open .txt files if (-T $filename) # checks to see if the file is a text file { open IN, "<", $filename or die &cant_open_file; print join "", <IN>; close IN; } else { &cant_open_file; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: escaping filenames taken in via user input
by Aristotle (Chancellor) on Oct 30, 2002 at 00:57 UTC | |
by stupidius (Initiate) on Oct 30, 2002 at 01:21 UTC | |
|
Re: Re: escaping filenames taken in via user input
by revdiablo (Prior) on Oct 30, 2002 at 02:18 UTC | |
by Aristotle (Chancellor) on Oct 30, 2002 at 02:30 UTC |