Changeset 51939 for trunk/src/wp-admin/includes/file.php
- Timestamp:
- 10/27/2021 02:58:24 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/file.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/file.php
r51899 r51939 1113 1113 * @since 2.5.0 1114 1114 * @since 5.2.0 Signature Verification with SoftFail was added. 1115 * @since 5.9.0 Support for Content-Disposition filename was added. 1115 1116 * 1116 1117 * @param string $url The URL of the file to download. … … 1181 1182 1182 1183 return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ), $data ); 1184 } 1185 1186 $content_disposition = wp_remote_retrieve_header( $response, 'content-disposition' ); 1187 1188 if ( $content_disposition ) { 1189 $content_disposition = strtolower( $content_disposition ); 1190 1191 if ( 0 === strpos( $content_disposition, 'attachment; filename=' ) ) { 1192 $tmpfname_disposition = sanitize_file_name( substr( $content_disposition, 21 ) ); 1193 } else { 1194 $tmpfname_disposition = ''; 1195 } 1196 1197 // Potential file name must be valid string 1198 if ( $tmpfname_disposition && is_string( $tmpfname_disposition ) && ( 0 === validate_file( $tmpfname_disposition ) ) ) { 1199 if ( rename( $tmpfname, $tmpfname_disposition ) ) { 1200 $tmpfname = $tmpfname_disposition; 1201 } 1202 1203 if ( ( $tmpfname !== $tmpfname_disposition ) && file_exists( $tmpfname_disposition ) ) { 1204 unlink( $tmpfname_disposition ); 1205 } 1206 } 1183 1207 } 1184 1208
Note: See TracChangeset
for help on using the changeset viewer.