Changeset 43395 for branches/4.7/src/wp-includes/functions.php
- Timestamp:
- 07/05/2018 02:50:26 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7/src/wp-includes/functions.php
r42275 r43395 1700 1700 * @since 4.4.0 Ensures upper-case drive letters on Windows systems. 1701 1701 * @since 4.5.0 Allows for Windows network shares. 1702 * @since 4.9.7 Allows for PHP file wrappers. 1702 1703 * 1703 1704 * @param string $path Path to normalize. … … 1705 1706 */ 1706 1707 function wp_normalize_path( $path ) { 1708 $wrapper = ''; 1709 if ( wp_is_stream( $path ) ) { 1710 list( $wrapper, $path ) = explode( '://', $path, 2 ); 1711 $wrapper .= '://'; 1712 } 1713 1714 // Standardise all paths to use / 1707 1715 $path = str_replace( '\\', '/', $path ); 1716 1717 // Replace multiple slashes down to a singular, allowing for network shares having two slashes. 1708 1718 $path = preg_replace( '|(?<=.)/+|', '/', $path ); 1719 1720 // Windows paths should uppercase the drive letter 1709 1721 if ( ':' === substr( $path, 1, 1 ) ) { 1710 1722 $path = ucfirst( $path ); 1711 1723 } 1712 return $path; 1724 1725 return $wrapper . $path; 1713 1726 } 1714 1727 … … 5447 5460 5448 5461 /** 5462 * Deletes a file if its path is within the given directory. 5463 * 5464 * @since 4.9.7 5465 * 5466 * @param string $file Absolute path to the file to delete. 5467 * @param string $directory Absolute path to a directory. 5468 * @return bool True on success, false on failure. 5469 */ 5470 function wp_delete_file_from_directory( $file, $directory ) { 5471 $real_file = realpath( wp_normalize_path( $file ) ); 5472 $real_directory = realpath( wp_normalize_path( $directory ) ); 5473 5474 if ( false === $real_file || false === $real_directory || strpos( wp_normalize_path( $real_file ), trailingslashit( wp_normalize_path( $real_directory ) ) ) !== 0 ) { 5475 return false; 5476 } 5477 5478 wp_delete_file( $file ); 5479 5480 return true; 5481 } 5482 5483 /** 5449 5484 * Outputs a small JS snippet on preview tabs/windows to remove `window.name` on unload. 5450 5485 *
Note: See TracChangeset
for help on using the changeset viewer.