|
1 | 1 | <?php |
2 | | -// $Id: file.inc,v 1.220 2010-08-01 01:33:42 webchick Exp $ |
| 2 | +// $Id: file.inc,v 1.221 2010-08-08 01:37:34 dries Exp $ |
3 | 3 |
|
4 | 4 | /** |
5 | 5 | * @file |
@@ -850,11 +850,23 @@ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXIST |
850 | 850 | /** |
851 | 851 | * Modify a filename as needed for security purposes. |
852 | 852 | * |
853 | | - * Dangerous file names will be altered; for instance, the file name |
854 | | - * "exploit.php.pps" will become "exploit.php_.pps". All extensions that are |
| 853 | + * Munging a file name prevents unknown file extensions from masking exploit |
| 854 | + * files. When web servers such as Apache decide how to process a URL request, |
| 855 | + * they use the file extension. If the extension is not recognized, Apache |
| 856 | + * skips that extension and uses the previous file extension. For example, if |
| 857 | + * the file being requested is exploit.php.pps, and Apache does not recognize |
| 858 | + * the '.pps' extension, it treats the file as PHP and executes it. To make |
| 859 | + * this file name safe for Apache and prevent it from executing as PHP, the |
| 860 | + * .php extension is "munged" into .php_, making the safe file name |
| 861 | + * exploit.php_.pps. |
| 862 | + * |
| 863 | + * Specifically, this function adds an underscore to all extensions that are |
855 | 864 | * between 2 and 5 characters in length, internal to the file name, and not |
856 | | - * included in $extensions will be altered by adding an underscore. If variable |
857 | | - * 'allow_insecure_uploads' evaluates to TRUE, no alterations will be made. |
| 865 | + * included in $extensions. |
| 866 | + * |
| 867 | + * Function behavior is also controlled by the Drupal variable |
| 868 | + * 'allow_insecure_uploads'. If 'allow_insecure_uploads' evaluates to TRUE, no |
| 869 | + * alterations will be made, if it evaluates to FALSE, the filename is 'munged'. |
858 | 870 | * |
859 | 871 | * @param $filename |
860 | 872 | * File name to modify. |
|
0 commit comments