Skip to content

Commit

Permalink
Merge pull request #31178 from owncloud/stable10-fix-31170
Browse files Browse the repository at this point in the history
[Stable10] Fix appwebpath detection when OC installed into the subdir and approot is a sibling of oc root dir
  • Loading branch information
Vincent Petry authored Apr 18, 2018
2 parents 06c30ef + b5450c8 commit 959efd1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 8 deletions.
4 changes: 3 additions & 1 deletion lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,9 @@ public function getAppWebPath($appId) {
$appRoot['url'] = substr($appRoot['url'], 3);
$ocWebRoot = dirname($ocWebRoot);
}
return $ocWebRoot . '/' . ltrim($appRoot['url'], '/');
$trimmedOcWebRoot = rtrim($ocWebRoot, '/');
$trimmedAppRoot = ltrim($appRoot['url'], '/');
return "$trimmedOcWebRoot/$trimmedAppRoot";
}
return false;
}
Expand Down
56 changes: 49 additions & 7 deletions tests/lib/App/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,15 @@ public function testPathIsNotCachedForNotFoundApp() {
$this->assertFalse($appPath);
}

public function testAppWebRootAboveOcWebroot() {
/**
* @dataProvider appAboveWebRootDataProvider
*
* @param string $ocWebRoot
* @param string[] $appData
* @param string $expectedAppWebPath
*/
public function testAppWebRootAboveOcWebRoot($ocWebRoot, $appData,
$expectedAppWebPath) {
$appId = 'notexistingapp';

$appManager = $this->getMockBuilder(AppManager::class)
Expand All @@ -540,17 +548,51 @@ public function testAppWebRootAboveOcWebroot() {

$appManager->expects($this->any())
->method('getOcWebRoot')
->willReturn('some/host/path');
->willReturn($ocWebRoot);

$appManager->expects($this->any())
->method('findAppInDirectories')
->with($appId)
->willReturn([
'path' => '/not/essential',
'url' => '../../relative',
]);
->willReturn($appData);

$appWebPath = $appManager->getAppWebPath($appId);
$this->assertEquals('some/relative', $appWebPath);
$this->assertEquals($expectedAppWebPath, $appWebPath);
}

public function appAboveWebRootDataProvider(){
return [
[
'/some/host/path',
[
'path' => '/not/essential',
'url' => '../../relative',
],
'/some/relative'
],
[
'/some/host/path',
[
'path' => '/not/essential',
'url' => '../relative',
],
'/some/host/relative'
],
[
'/some/hostPath',
[
'path' => '/not/essential',
'url' => '../relative',
],
'/some/relative'
],
[
'/someHostPath',
[
'path' => '/not/essential',
'url' => '../relative',
],
'/relative'
],
];
}
}

0 comments on commit 959efd1

Please sign in to comment.