Merge pull request #28726 from nextcloud/check-if-path-is-valid

Check if SVG path is valid
This commit is contained in:
Lukas Reschke 2021-09-07 08:31:16 +02:00 committed by GitHub
commit d4d1f5dfce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -31,6 +31,7 @@ declare(strict_types=1);
*/
namespace OC\Core\Controller;
use OC\Files\Filesystem;
use OC\Template\IconsCacher;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
@ -117,6 +118,10 @@ class SvgController extends Controller {
* @return DataDisplayResponse|NotFoundResponse
*/
private function getSvg(string $path, string $color, string $fileName) {
if (!Filesystem::isValidPath($path)) {
return new NotFoundResponse();
}
if (!file_exists($path)) {
return new NotFoundResponse();
}

View file

@ -183,7 +183,7 @@ class SvgControllerTest extends TestCase {
$this->appManager->expects($this->once())
->method('getAppPath')
->with($appName)
->willReturn(__DIR__ . '/../../../apps/' . $appName);
->willReturn(realpath(__DIR__ . '/../../../apps/') . '/' . $appName);
$response = $this->svgController->getSvgFromApp($appName, $name, $color);