WordPress.org

Make WordPress Core

Ticket #33053: file.php.2.patch

File file.php.2.patch, 1.6 KB (added by liegeandlief, 5 years ago)

file.php altered to prevent unzip working direcotry path from being too long

Line 
1141a142
2>               $this->strings['working_dir_filepath_too_long'] = __('Working directory path length is too long.');
3282,284c283,305
4<
5<               // We need a working directory - Strip off any .tmp or .zip suffixes
6<               $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
7---
8>               
9>               //Strip off any .tmp or .zip suffixes from temporary package filename
10>               $tmp_filename_no_suffix = basename( basename( $package, '.tmp' ), '.zip' );
11>
12>               // We need a working directory
13>               $working_dir = $upgrade_folder . $tmp_filename_no_suffix;
14>               
15>               /* Filepaths should be 255 characters or fewer to prevent errors on Windows installations.
16>               If working directory path is longer than 255 characters then try to remove some
17>               characters from the temporary directory name to bring it within 255 characters. */
18>               $how_much_too_long = strlen($working_dir)-255;
19>               
20>               if ($how_much_too_long > 0) {
21>                       $tmp_filename_no_suffix_length = strlen($tmp_filename_no_suffix);
22>                       /* If the length by which the working directory filepath is too long is greater
23>                       than or equal to the length of the temporary directory's name then throw an error
24>                       as we will not be able to create a short enough working directory path. */
25>                       if ($how_much_too_long >= $tmp_filename_no_suffix_length) {
26>                               return new WP_Error( 'working_dir_filepath_too_long', $this->strings['working_dir_filepath_too_long'] );
27>                       }
28>                       $shortened_directory_name = substr($tmp_filename_no_suffix, 0, $tmp_filename_no_suffix_length-$how_much_too_long);
29>                       $working_dir = $upgrade_folder . $shortened_directory_name;
30>               }