diff options
author | Kyle Fazzari <kyrofa@ubuntu.com> | 2018-02-21 09:44:37 +0300 |
---|---|---|
committer | Kyle Fazzari <kyrofa@ubuntu.com> | 2018-02-21 09:45:10 +0300 |
commit | a1f18241166f335b89a6cf3d002efd3d825fde19 (patch) | |
tree | a0e2a5bab83f4c87b0e04ef03b4f730a904b7ce4 /apps/theming/lib/Controller | |
parent | 6591a3bc366874ead2de646ae1ca920277c17bff (diff) |
theming: handle not being in the serverroot
Currently, the theming app assumes it's in the serverroot. However, with
Nextcloud's flexibility regarding configurable app paths, this is not a
safe assumption to make. If it happens to be an incorrect assumption,
the theming app fails to work.
Instead of relying on the serverroot, just use the path from the
AppManager and utilize relative paths for assets from there.
Fix #8462
Signed-off-by: Kyle Fazzari <kyrofa@ubuntu.com>
Diffstat (limited to 'apps/theming/lib/Controller')
-rw-r--r-- | apps/theming/lib/Controller/ThemingController.php | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php index 4e9ce1b646e..f41b9062a11 100644 --- a/apps/theming/lib/Controller/ThemingController.php +++ b/apps/theming/lib/Controller/ThemingController.php @@ -51,6 +51,7 @@ use OCP\IRequest; use OCA\Theming\Util; use OCP\ITempManager; use OCP\IURLGenerator; +use OCP\App\IAppManager; /** * Class ThemingController @@ -78,6 +79,8 @@ class ThemingController extends Controller { private $scssCacher; /** @var IURLGenerator */ private $urlGenerator; + /** @var IAppManager */ + private $appManager; /** * ThemingController constructor. @@ -93,6 +96,7 @@ class ThemingController extends Controller { * @param IAppData $appData * @param SCSSCacher $scssCacher * @param IURLGenerator $urlGenerator + * @param IAppManager $appManager */ public function __construct( $appName, @@ -105,7 +109,8 @@ class ThemingController extends Controller { ITempManager $tempManager, IAppData $appData, SCSSCacher $scssCacher, - IURLGenerator $urlGenerator + IURLGenerator $urlGenerator, + IAppManager $appManager = NULL ) { parent::__construct($appName, $request); @@ -118,6 +123,12 @@ class ThemingController extends Controller { $this->appData = $appData; $this->scssCacher = $scssCacher; $this->urlGenerator = $urlGenerator; + + if (!is_null($appManager)) { + $this->appManager = $appManager; + } else { + $this->appManager = \OC::$server->getAppManager(); + } } /** @@ -409,12 +420,13 @@ class ThemingController extends Controller { * @return FileDisplayResponse|NotFoundResponse */ public function getStylesheet() { - $appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1); + $appPath = $this->appManager->getAppPath('theming'); + /* SCSSCacher is required here * We cannot rely on automatic caching done by \OC_Util::addStyle, * since we need to add the cacheBuster value to the url */ - $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming'); + $cssCached = $this->scssCacher->process($appPath, 'css/theming.scss', 'theming'); if(!$cssCached) { return new NotFoundResponse(); } |