mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Media: Account for Windows when normalizing file paths.
Previously, Windows paths in the `path_is_absolute` function resulted in incorrect URIs. This patch adjusts for forward slashes and adds tests for the `get_attached_file` function. Props Whissi, SergeyBiryukov, desrosj, stevenlinx, birgire, davidbaumwald, costdev, peterwilsoncc, audrasjb, hellofromTonya, johnbillion. Fixes #36308. git-svn-id: https://develop.svn.wordpress.org/trunk@53934 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2083,6 +2083,7 @@ function wp_mkdir_p( $target ) {
|
||||
* For example, '/foo/bar', or 'c:\windows'.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @since 6.1.0 Allows normalized Windows paths (forward slashes).
|
||||
*
|
||||
* @param string $path File path.
|
||||
* @return bool True if path is absolute, false is not absolute.
|
||||
@@ -2113,6 +2114,11 @@ function path_is_absolute( $path ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Normalized Windows paths for local filesystem and network shares (forward slashes).
|
||||
if ( preg_match( '#(^[a-zA-Z]+:/|^//[\w!@\#\$%\^\(\)\-\'{}\.~]{1,15})#', $path ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// A path starting with / or \ is absolute; anything else is relative.
|
||||
return ( '/' === $path[0] || '\\' === $path[0] );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user