Skip to content

Commit

Permalink
return non escaped path from exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Aug 26, 2016
1 parent 0809553 commit 82f9618
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/NativeState.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,15 @@ protected function handleError($path) {
}
}

protected function testResult($result, $path) {
protected function testResult($result, $uri) {
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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public function getName() {
}

protected function simpleCommand($command, $path) {
$path = $this->escapePath($path);
$cmd = $command . ' ' . $path;
$escapedPath = $this->escapePath($path);
$cmd = $command . ' ' . $escapedPath;
$output = $this->execute($cmd);
return $this->parseOutput($output, $path);
}
Expand Down
10 changes: 10 additions & 0 deletions tests/AbstractShare.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Icewind\SMB\Test;

use Icewind\SMB\Exception\InvalidPathException;
use Icewind\SMB\Exception\NotFoundException;
use Icewind\SMB\FileInfo;

abstract class AbstractShare extends TestCase {
Expand Down Expand Up @@ -257,6 +258,15 @@ public function testDel($name) {
$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
*/
Expand Down

0 comments on commit 82f9618

Please sign in to comment.