summaryrefslogtreecommitdiffstats
path: root/lib/private/Template
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2016-11-10 16:16:33 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2017-01-06 09:42:13 +0100
commit3b62003c9c085dc76357220fc83f14bcf96c60a2 (patch)
treee30b5286208c5dff3c0fc58c8dc9e37e47bc4464 /lib/private/Template
parent2f5f1096ad3d754ae4e55d5e53be44e5bba9db19 (diff)
downloadnextcloud-server-3b62003c9c085dc76357220fc83f14bcf96c60a2.tar.gz
nextcloud-server-3b62003c9c085dc76357220fc83f14bcf96c60a2.zip
Injection fix and log appname fix
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib/private/Template')
-rwxr-xr-xlib/private/Template/CSSResourceLocator.php14
-rwxr-xr-xlib/private/Template/ResourceLocator.php8
-rwxr-xr-xlib/private/Template/SCSSCacher.php17
3 files changed, 28 insertions, 11 deletions
diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php
index 0d190959ea1..8e1cb3a761a 100755
--- a/lib/private/Template/CSSResourceLocator.php
+++ b/lib/private/Template/CSSResourceLocator.php
@@ -27,7 +27,12 @@ namespace OC\Template;
class CSSResourceLocator extends ResourceLocator {
+ /** @var IAppData */
protected $appData;
+ /** @var \OCP\IURLGenerator */
+ protected $urlGenerator;
+ /** @var \OCP\Files\IConfig */
+ protected $systemConfig;
/**
* @param \OCP\ILogger $logger
@@ -36,8 +41,11 @@ class CSSResourceLocator extends ResourceLocator {
* @param array $party_map
* @param IAppData $appData
*/
- public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map, $appData) {
+ public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map, \OCP\Files\IAppData $appData, \OCP\IURLGenerator $urlGenerator, $systemConfig) {
$this->appData = $appData;
+ $this->urlGenerator = $urlGenerator;
+ $this->systemConfig = $systemConfig;
+
parent::__construct($logger, $theme, $core_map, $party_map);
}
@@ -47,8 +55,8 @@ class CSSResourceLocator extends ResourceLocator {
public function doFind($style) {
if (strpos($style, '3rdparty') === 0
&& $this->appendIfExist($this->thirdpartyroot, $style.'.css')
- || $this->cacheAndAppendScssIfExist($this->serverroot, $style.'.scss', $this->appData)
- || $this->cacheAndAppendScssIfExist($this->serverroot, 'core/'.$style.'.scss', $this->appData)
+ || $this->cacheAndAppendScssIfExist($this->serverroot, $style.'.scss', $this->appData, $this->urlGenerator, $this->systemConfig)
+ || $this->cacheAndAppendScssIfExist($this->serverroot, 'core/'.$style.'.scss', $this->appData, $this->urlGenerator, $this->systemConfig)
|| $this->appendIfExist($this->serverroot, $style.'.css')
|| $this->appendIfExist($this->serverroot, 'core/'.$style.'.css')
) {
diff --git a/lib/private/Template/ResourceLocator.php b/lib/private/Template/ResourceLocator.php
index bb4cfa94f6c..d5187ef0710 100755
--- a/lib/private/Template/ResourceLocator.php
+++ b/lib/private/Template/ResourceLocator.php
@@ -115,19 +115,21 @@ abstract class ResourceLocator {
* @param string|null $webRoot base for path, default map $root to $webRoot
* @return bool True if the resource was found and cached, false otherwise
*/
- protected function cacheAndAppendScssIfExist($root, $file, $appData, $webRoot = null) {
+ protected function cacheAndAppendScssIfExist($root, $file, $appData, $urlGenerator, $systemConfig, $webRoot = null) {
if (is_file($root.'/'.$file)) {
$scssCache = new \OC\Template\SCSSCacher(
$this->logger,
$root,
$file,
- $appData);
+ $appData,
+ $urlGenerator,
+ $systemConfig);
if($scssCache->process()) {
$this->append($root, $scssCache->getCachedSCSS(), $webRoot, false);
return true;
} else {
- $this->logger->error('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'server']);
+ $this->logger->error('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']);
return false;
}
}
diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php
index 42f3e1758f8..a5f4f510204 100755
--- a/lib/private/Template/SCSSCacher.php
+++ b/lib/private/Template/SCSSCacher.php
@@ -40,6 +40,10 @@ class SCSSCacher {
protected $logger;
/** @var \OCP\Files\IAppData */
protected $appData;
+ /** @var \OCP\IURLGenerator */
+ protected $urlGenerator;
+ /** @var \OCP\Files\IConfig */
+ protected $systemConfig;
/**
* @param \OCP\ILogger $logger
@@ -47,9 +51,12 @@ class SCSSCacher {
* @param string $file
* @param \OCP\Files\IAppData $appData
*/
- public function __construct(\OCP\ILogger $logger, $root, $file, $appData) {
+ public function __construct(\OCP\ILogger $logger, $root, $file, \OCP\Files\IAppData $appData, \OCP\IURLGenerator $urlGenerator, $systemConfig) {
$this->logger = $logger;
$this->appData = $appData;
+ $this->urlGenerator = $urlGenerator;
+ $this->systemConfig = $systemConfig;
+
$this->root = $root;
$this->file = explode('/', $root.'/'.$file);
@@ -110,7 +117,7 @@ class SCSSCacher {
private function cache() {
$scss = new Compiler();
$scss->setImportPaths($this->fileLoc);
- if(\OC::$server->getSystemConfig()->getValue('debug')) {
+ if($this->systemConfig->getValue('debug')) {
// Debug mode
$scss->setFormatter('Leafo\ScssPhp\Formatter\Expanded');
$scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
@@ -129,13 +136,13 @@ class SCSSCacher {
try {
$compiledScss = $scss->compile('@import "'.$this->fileNameSCSS.'";');
} catch(ParserException $e) {
- $this->logger->error($e, ['app' => 'server']);
+ $this->logger->error($e, ['app' => 'core']);
return false;
}
try {
$cachedfile->putContent($this->rebaseUrls($compiledScss));
- $this->logger->debug($this->rootCssLoc.'/'.$this->fileNameSCSS.' compiled and successfully cached', ['app' => 'server']);
+ $this->logger->debug($this->rootCssLoc.'/'.$this->fileNameSCSS.' compiled and successfully cached', ['app' => 'core']);
return true;
} catch(NotFoundException $e) {
return false;
@@ -159,6 +166,6 @@ class SCSSCacher {
* @return string
*/
public function getCachedSCSS() {
- return substr(\OC::$server->getURLGenerator()->linkToRoute('core.Css.getCss', array('fileName' => $this->fileNameCSS)), 1);
+ return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $this->fileNameCSS)), 1);
}
}