Changeset 43393 for branches/4.9/src/wp-includes/functions.php
- Timestamp:
- 07/05/2018 02:44:35 PM (7 years ago)
- File:
-
- 1 edited
-
branches/4.9/src/wp-includes/functions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9/src/wp-includes/functions.php
r43285 r43393 1705 1705 * @since 4.4.0 Ensures upper-case drive letters on Windows systems. 1706 1706 * @since 4.5.0 Allows for Windows network shares. 1707 * @since 4.9.7 Allows for PHP file wrappers. 1707 1708 * 1708 1709 * @param string $path Path to normalize. … … 1710 1711 */ 1711 1712 function wp_normalize_path( $path ) { 1713 $wrapper = ''; 1714 if ( wp_is_stream( $path ) ) { 1715 list( $wrapper, $path ) = explode( '://', $path, 2 ); 1716 $wrapper .= '://'; 1717 } 1718 1719 // Standardise all paths to use / 1712 1720 $path = str_replace( '\\', '/', $path ); 1721 1722 // Replace multiple slashes down to a singular, allowing for network shares having two slashes. 1713 1723 $path = preg_replace( '|(?<=.)/+|', '/', $path ); 1724 1725 // Windows paths should uppercase the drive letter 1714 1726 if ( ':' === substr( $path, 1, 1 ) ) { 1715 1727 $path = ucfirst( $path ); 1716 1728 } 1717 return $path; 1729 1730 return $wrapper . $path; 1718 1731 } 1719 1732 … … 5505 5518 5506 5519 /** 5520 * Deletes a file if its path is within the given directory. 5521 * 5522 * @since 4.9.7 5523 * 5524 * @param string $file Absolute path to the file to delete. 5525 * @param string $directory Absolute path to a directory. 5526 * @return bool True on success, false on failure. 5527 */ 5528 function wp_delete_file_from_directory( $file, $directory ) { 5529 $real_file = realpath( wp_normalize_path( $file ) ); 5530 $real_directory = realpath( wp_normalize_path( $directory ) ); 5531 5532 if ( false === $real_file || false === $real_directory || strpos( wp_normalize_path( $real_file ), trailingslashit( wp_normalize_path( $real_directory ) ) ) !== 0 ) { 5533 return false; 5534 } 5535 5536 wp_delete_file( $file ); 5537 5538 return true; 5539 } 5540 5541 /** 5507 5542 * Outputs a small JS snippet on preview tabs/windows to remove `window.name` on unload. 5508 5543 *
Note: See TracChangeset
for help on using the changeset viewer.