Skip to content
Permalink
Browse files

Fix file:// paths being mishandled on windows.

While I don't think its feasible to fix all the cases reported in #7275
as certain paths have different meaning in windows, we can fix file://
not working.

Refs #7275
  • Loading branch information...
markstory committed Dec 22, 2015
1 parent a026b0c commit 5714cf14a9ca4b439b872aaf3ad6e5bfddda46ad
Showing with 19 additions and 4 deletions.
  1. +1 −2 src/Filesystem/Folder.php
  2. +18 −2 tests/TestCase/Filesystem/FileTest.php
@@ -286,7 +286,6 @@ public static function isAbsolute($path)
if (empty($path)) {
return false;
}
return $path[0] === '/' ||
preg_match('/^[A-Z]:\\\\/i', $path) ||
substr($path, 0, 2) === '\\\\' ||
@@ -827,13 +826,13 @@ public function errors($reset = true)
*/
public function realpath($path)
{
$path = str_replace('/', DIRECTORY_SEPARATOR, trim($path));
if (strpos($path, '..') === false) {
if (!Folder::isAbsolute($path)) {
$path = Folder::addPathElement($this->path, $path);
}
return $path;
}
$path = str_replace('/', DIRECTORY_SEPARATOR, trim($path));
$parts = explode(DIRECTORY_SEPARATOR, $path);
$newparts = [];
$newpath = '';
@@ -1,7 +1,5 @@
<?php
/**
* FileTest file
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@@ -293,6 +291,24 @@ public function testCreate()
$this->assertTrue($File->exists());
}
/**
* Tests the exists() method.
*
* @return void
*/
public function testExists()
{
$tmpFile = TMP . 'tests/cakephp.file.test.tmp';
$file = new File($tmpFile, true, 0777);
$this->assertTrue($file->exists(), 'absolute path should exist');
$file = new File('file://' . $tmpFile, false);
$this->assertTrue($file->exists(), 'file:// should exist.');
$file = new File('/something/bad', false);
$this->assertFalse($file->exists(), 'missing file should not exist.');
}
/**
* testOpeningNonExistentFileCreatesIt method
*

0 comments on commit 5714cf1

Please sign in to comment.
You can’t perform that action at this time.