Changeset 43397 for branches/4.5/src/wp-includes/functions.php
- Timestamp:
- 07/05/2018 02:54:32 PM (8 years ago)
- File:
-
- 1 edited
-
branches/4.5/src/wp-includes/functions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/4.5/src/wp-includes/functions.php
r42283 r43397 1694 1694 * @since 4.4.0 Ensures upper-case drive letters on Windows systems. 1695 1695 * @since 4.5.0 Allows for Windows network shares. 1696 * @since 4.9.7 Allows for PHP file wrappers. 1696 1697 * 1697 1698 * @param string $path Path to normalize. … … 1699 1700 */ 1700 1701 function wp_normalize_path( $path ) { 1702 $wrapper = ''; 1703 if ( wp_is_stream( $path ) ) { 1704 list( $wrapper, $path ) = explode( '://', $path, 2 ); 1705 $wrapper .= '://'; 1706 } 1707 1708 // Standardise all paths to use / 1701 1709 $path = str_replace( '\\', '/', $path ); 1710 1711 // Replace multiple slashes down to a singular, allowing for network shares having two slashes. 1702 1712 $path = preg_replace( '|(?<=.)/+|', '/', $path ); 1713 1714 // Windows paths should uppercase the drive letter 1703 1715 if ( ':' === substr( $path, 1, 1 ) ) { 1704 1716 $path = ucfirst( $path ); 1705 1717 } 1706 return $path; 1718 1719 return $wrapper . $path; 1707 1720 } 1708 1721 … … 5273 5286 5274 5287 /** 5288 * Deletes a file if its path is within the given directory. 5289 * 5290 * @since 4.9.7 5291 * 5292 * @param string $file Absolute path to the file to delete. 5293 * @param string $directory Absolute path to a directory. 5294 * @return bool True on success, false on failure. 5295 */ 5296 function wp_delete_file_from_directory( $file, $directory ) { 5297 $real_file = realpath( wp_normalize_path( $file ) ); 5298 $real_directory = realpath( wp_normalize_path( $directory ) ); 5299 5300 if ( false === $real_file || false === $real_directory || strpos( wp_normalize_path( $real_file ), trailingslashit( wp_normalize_path( $real_directory ) ) ) !== 0 ) { 5301 return false; 5302 } 5303 5304 wp_delete_file( $file ); 5305 5306 return true; 5307 } 5308 5309 /** 5275 5310 * Outputs a small JS snippet on preview tabs/windows to remove `window.name` on unload. 5276 5311 *
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)