diff options
author | MichaIng <micha@dietpi.com> | 2021-06-20 13:20:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-20 13:20:10 +0300 |
commit | 4f47bec782c90d89a501e7ed5ed43c2816a8ce81 (patch) | |
tree | ad5bac61b7a005a92f234a44531354ff6ab24032 /core/Controller/SvgController.php | |
parent | 4d51ed3918032c44df612fad6b2c12b0e9eff693 (diff) | |
parent | 61a31dcdd73aae9a728551421116c5947e5b3089 (diff) |
Merge branch 'master' into improve-contributing-docsimprove-contributing-docs
Diffstat (limited to 'core/Controller/SvgController.php')
-rw-r--r-- | core/Controller/SvgController.php | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/core/Controller/SvgController.php b/core/Controller/SvgController.php index 63105e1c0f1..ea73ba118d9 100644 --- a/core/Controller/SvgController.php +++ b/core/Controller/SvgController.php @@ -5,12 +5,13 @@ declare(strict_types=1); /** * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv@protonmail.com) * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> + * @author Daniel Kesselberg <mail@danielkesselberg.de> * @author Joas Schilling <coding@schilljs.com> - * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> + * @author John Molakvoæ <skjnldsv@protonmail.com> * @author Julius Härtl <jus@bitgrid.net> - * @author Michael Weimann <mail@michael-weimann.eu> * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Citharel <tcit@tcit.fr> + * @author Thomas Citharel <nextcloud@tcit.fr> * * @license GNU AGPL version 3 or any later version * @@ -21,17 +22,17 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ - namespace OC\Core\Controller; use OC\Template\IconsCacher; +use OCP\App\AppPathNotFoundException; use OCP\App\IAppManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; @@ -61,7 +62,7 @@ class SvgController extends Controller { IconsCacher $iconsCacher) { parent::__construct($appName, $request); - $this->serverRoot = \OC::$SERVERROOT; + $this->serverRoot = \OC::$SERVERROOT; $this->timeFactory = $timeFactory; $this->appManager = $appManager; $this->iconsCacher = $iconsCacher; @@ -97,13 +98,13 @@ class SvgController extends Controller { * @return DataDisplayResponse|NotFoundResponse */ public function getSvgFromApp(string $app, string $fileName, string $color = 'ffffff') { - $appRootPath = $this->appManager->getAppPath($app); - $appPath = substr($appRootPath, strlen($this->serverRoot)); - - if (!$appPath) { + try { + $appPath = $this->appManager->getAppPath($app); + } catch (AppPathNotFoundException $e) { return new NotFoundResponse(); } - $path = $this->serverRoot . $appPath ."/img/$fileName.svg"; + + $path = $appPath . "/img/$fileName.svg"; return $this->getSvg($path, $color, $fileName); } |