Skip to content

Commit 6889d88

Browse files
committed
return non escaped path from exceptions
1 parent 0809553 commit 6889d88

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/NativeState.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,14 @@ protected function handleError($path) {
6363
}
6464
}
6565

66-
protected function testResult($result, $path) {
66+
protected function testResult($result, $uri) {
6767
if ($result === false or $result === null) {
68+
// smb://host/share/path
69+
if (is_string($uri)) {
70+
list(, , , , $path) = explode('/', $uri, 5);
71+
} else {
72+
$path = null;
73+
}
6874
$this->handleError($path);
6975
}
7076
}

src/Share.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ public function getName() {
9999
}
100100

101101
protected function simpleCommand($command, $path) {
102-
$path = $this->escapePath($path);
103-
$cmd = $command . ' ' . $path;
102+
$escapedPath = $this->escapePath($path);
103+
$cmd = $command . ' ' . $escapedPath;
104104
$output = $this->execute($cmd);
105105
return $this->parseOutput($output, $path);
106106
}

tests/AbstractShare.php

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Icewind\SMB\Test;
99

1010
use Icewind\SMB\Exception\InvalidPathException;
11+
use Icewind\SMB\Exception\NotFoundException;
1112
use Icewind\SMB\FileInfo;
1213

1314
abstract class AbstractShare extends TestCase {
@@ -257,6 +258,15 @@ public function testDel($name) {
257258
$this->assertCount(0, $this->share->dir($this->root));
258259
}
259260

261+
public function testNotFoundExceptionPath() {
262+
try {
263+
$this->share->mkdir($this->root . '/foo/bar');
264+
$this->fail();
265+
} catch(NotFoundException $e) {
266+
$this->assertEquals($this->root . '/foo/bar', $e->getPath());
267+
}
268+
}
269+
260270
/**
261271
* @expectedException \Icewind\SMB\Exception\NotFoundException
262272
*/

0 commit comments

Comments
 (0)