diff options
author | tux-rampage <tux-rampage@users.noreply.github.com> | 2017-09-06 21:28:45 +0200 |
---|---|---|
committer | tux-rampage <tux-rampage@users.noreply.github.com> | 2017-09-06 21:32:48 +0200 |
commit | 7a33b9273e2e51ec2654fc76035bce18abefcbb7 (patch) | |
tree | 33c1a3ec06ddc2d68a20a91adefc345d2dad5021 /lib/private/Template/CSSResourceLocator.php | |
parent | a10c4517cbb20625b5ee32c1809bee40ecbb5456 (diff) | |
download | nextcloud-server-7a33b9273e2e51ec2654fc76035bce18abefcbb7.tar.gz nextcloud-server-7a33b9273e2e51ec2654fc76035bce18abefcbb7.zip |
Refactor webroot detection in resource locator
The current implementation breaks installations with symlinks to
directories inside the webroot (i.E. apps).
With this change both variants, directory and symlinks, will be detected
correctly.
Fixes: #6028
Signed-off-by: Axel Helmert <axel.helmert@luka.de>
Diffstat (limited to 'lib/private/Template/CSSResourceLocator.php')
-rw-r--r-- | lib/private/Template/CSSResourceLocator.php | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php index 32dabb48c0d..1b4050e4ae0 100644 --- a/lib/private/Template/CSSResourceLocator.php +++ b/lib/private/Template/CSSResourceLocator.php @@ -117,38 +117,18 @@ class CSSResourceLocator extends ResourceLocator { parent::append($root, $file, $webRoot, $throw); } else { if (!$webRoot) { - $tmpRoot = realpath($root); - /* - * traverse the potential web roots upwards in the path - * - * example: - * - root: /srv/www/apps/myapp - * - available mappings: ['/srv/www'] - * - * First we check if a mapping for /srv/www/apps/myapp is available, - * then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a - * valid web root - */ - do { - if (isset($this->mapping[$tmpRoot])) { - $webRoot = $this->mapping[$tmpRoot]; - break; - } - - if ($tmpRoot === '/') { - $webRoot = ''; - $this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [ - 'app' => 'lib', - 'root' => $root, - 'file' => $file, - 'webRoot' => $webRoot, - 'throw' => $throw ? 'true' : 'false' - ]); - break; - } - $tmpRoot = dirname($tmpRoot); - } while(true); - + $webRoot = $this->findWebRoot($root); + + if (!$webRoot) { + $webRoot = ''; + $this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [ + 'app' => 'lib', + 'root' => $root, + 'file' => $file, + 'webRoot' => $webRoot, + 'throw' => $throw ? 'true' : 'false' + ]); + } } if ($throw && $tmpRoot === '/') { |