Merge pull request #3939 from nextcloud/downstream-27159

Fix malformed logging in exception
This commit is contained in:
Joas Schilling 2017-03-20 12:46:48 +01:00 committed by GitHub
commit 85a5c24934
2 changed files with 13 additions and 0 deletions

View file

@ -96,8 +96,12 @@ class View {
private $updaterEnabled = true;
/** @var \OC\User\Manager */
private $userManager;
/** @var \OCP\ILogger */
private $logger;
/**
* @param string $root
* @throws \Exception If $root contains an invalid path
@ -114,6 +118,7 @@ class View {
$this->lockingProvider = \OC::$server->getLockingProvider();
$this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider);
$this->userManager = \OC::$server->getUserManager();
$this->logger = \OC::$server->getLogger();
}
public function getAbsolutePath($path = '/') {
@ -2068,6 +2073,12 @@ class View {
$parts = explode('/', trim($path, '/'), 3);
// "$user", "files", "path/to/dir"
if (!isset($parts[1]) || $parts[1] !== 'files') {
$this->logger->error(
'$absolutePath must be relative to "files", value is "%s"',
[
$absolutePath
]
);
throw new \InvalidArgumentException('$absolutePath must be relative to "files"');
}
if (isset($parts[2])) {

View file

@ -1488,6 +1488,8 @@ class ViewTest extends \Test\TestCase {
/**
* @dataProvider pathRelativeToFilesProviderExceptionCases
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage $absolutePath must be relative to "files"
* @param string $path
*/
public function testGetPathRelativeToFilesWithInvalidArgument($path) {
$view = new View();