return non escaped path from exceptions

This commit is contained in:
Robin Appelman 2016-08-27 00:25:35 +02:00
commit 82f961896f
3 changed files with 20 additions and 3 deletions

View file

@ -63,8 +63,15 @@ class NativeState {
} }
} }
protected function testResult($result, $path) { protected function testResult($result, $uri) {
if ($result === false or $result === null) { if ($result === false or $result === null) {
// smb://host/share/path
if (is_string($uri)) {
list(, , , , $path) = explode('/', $uri, 5);
$path = '/' . $path;
} else {
$path = null;
}
$this->handleError($path); $this->handleError($path);
} }
} }

View file

@ -99,8 +99,8 @@ class Share extends AbstractShare {
} }
protected function simpleCommand($command, $path) { protected function simpleCommand($command, $path) {
$path = $this->escapePath($path); $escapedPath = $this->escapePath($path);
$cmd = $command . ' ' . $path; $cmd = $command . ' ' . $escapedPath;
$output = $this->execute($cmd); $output = $this->execute($cmd);
return $this->parseOutput($output, $path); return $this->parseOutput($output, $path);
} }

View file

@ -8,6 +8,7 @@
namespace Icewind\SMB\Test; namespace Icewind\SMB\Test;
use Icewind\SMB\Exception\InvalidPathException; use Icewind\SMB\Exception\InvalidPathException;
use Icewind\SMB\Exception\NotFoundException;
use Icewind\SMB\FileInfo; use Icewind\SMB\FileInfo;
abstract class AbstractShare extends TestCase { abstract class AbstractShare extends TestCase {
@ -257,6 +258,15 @@ abstract class AbstractShare extends TestCase {
$this->assertCount(0, $this->share->dir($this->root)); $this->assertCount(0, $this->share->dir($this->root));
} }
public function testNotFoundExceptionPath() {
try {
$this->share->mkdir($this->root . '/foo/bar');
$this->fail();
} catch(NotFoundException $e) {
$this->assertEquals($this->root . '/foo/bar', $e->getPath());
}
}
/** /**
* @expectedException \Icewind\SMB\Exception\NotFoundException * @expectedException \Icewind\SMB\Exception\NotFoundException
*/ */