mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +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:
@@ -105,6 +105,13 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
'C:\\',
|
||||
'C:\\WINDOWS',
|
||||
'\\\\sambashare\\foo',
|
||||
'c:/',
|
||||
'c://',
|
||||
'//',
|
||||
'c:/FOO',
|
||||
'//FOO',
|
||||
'C:/WWW/Sites/demo/htdocs/wordpress/wp-content/uploads/2016/03/example.jpg',
|
||||
'//ComputerName/ShareName/SubfolderName/example.txt',
|
||||
);
|
||||
foreach ( $absolute_paths as $path ) {
|
||||
$this->assertTrue( path_is_absolute( $path ), "path_is_absolute('$path') should return true" );
|
||||
@@ -119,10 +126,14 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
'../foo',
|
||||
'../',
|
||||
'../foo.bar',
|
||||
'foo.bar',
|
||||
'foo/bar',
|
||||
'foo',
|
||||
'FOO',
|
||||
'..\\WINDOWS',
|
||||
'..//WINDOWS',
|
||||
'c:',
|
||||
'C:',
|
||||
);
|
||||
foreach ( $relative_paths as $path ) {
|
||||
$this->assertFalse( path_is_absolute( $path ), "path_is_absolute('$path') should return false" );
|
||||
|
||||
Reference in New Issue
Block a user