diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-08-08 01:37:34 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-08-08 01:37:34 +0000 |
commit | 2aee69c3ced832a5f5a1aac6046859432f170218 (patch) | |
tree | 5ee63757030bd36aac57d141dbfa824078fa4b77 /includes | |
parent | 552acd74aefe838e7f3de69b9ca8ca1d31440be6 (diff) | |
download | brdo-2aee69c3ced832a5f5a1aac6046859432f170218.tar.gz brdo-2aee69c3ced832a5f5a1aac6046859432f170218.tar.bz2 |
- Patch #710640 by jhodgdon, torelad: improve documentation for file_munge_filename().
Diffstat (limited to 'includes')
-rw-r--r-- | includes/file.inc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/includes/file.inc b/includes/file.inc index 34cb472b2..68c16c109 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -850,11 +850,23 @@ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXIST /** * Modify a filename as needed for security purposes. * - * Dangerous file names will be altered; for instance, the file name - * "exploit.php.pps" will become "exploit.php_.pps". All extensions that are + * Munging a file name prevents unknown file extensions from masking exploit + * files. When web servers such as Apache decide how to process a URL request, + * they use the file extension. If the extension is not recognized, Apache + * skips that extension and uses the previous file extension. For example, if + * the file being requested is exploit.php.pps, and Apache does not recognize + * the '.pps' extension, it treats the file as PHP and executes it. To make + * this file name safe for Apache and prevent it from executing as PHP, the + * .php extension is "munged" into .php_, making the safe file name + * exploit.php_.pps. + * + * Specifically, this function adds an underscore to all extensions that are * between 2 and 5 characters in length, internal to the file name, and not - * included in $extensions will be altered by adding an underscore. If variable - * 'allow_insecure_uploads' evaluates to TRUE, no alterations will be made. + * included in $extensions. + * + * Function behavior is also controlled by the Drupal variable + * 'allow_insecure_uploads'. If 'allow_insecure_uploads' evaluates to TRUE, no + * alterations will be made, if it evaluates to FALSE, the filename is 'munged'. * * @param $filename * File name to modify. |