and should be defined after 'use CGI' statement. They generate errors is a POST is too large or the PUT method is used, which then can be caught by the script. (Example) See the CGI module documentation for more information.$CGI::POST_MAX=1024 * 100; # limits size of POST to 100k $CGI::DISABLE_UPLOADS = 1; # creates an error if PUT is attempted
& ; ` ' \ " | * ? ~ < > ^ ( ) [ ] { } $ \n \r
Perl provides a mechanism that prevents a script from passing unchecked input to variables. Any variable that is assigned data from outside the program is considered 'tainted' and can not be used to affect anything outside the program unless the variable is 'untainted'. A variable is 'untainted' by performing a pattern matching operation and extracting matched substrings. Hence, the script cannot executed an external command without explicitly looking for the command that is to be executed.
Taint checks are turned on by running a script with a '-T' flag.
#!/usr/local/bin/perl -T
With taint checks on, the script must also set the environmental variable $PATH
to any directories involved in running an external command.
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
Also, if the script use the Perl function require
, the path must be included when the 'required' script is in the same directory:
$file = "myfile.txt; require $file;
will cause an error. Instead, write
$file = "./myfile.txt; require $file;