Skip to content

Commit afac93b

Browse files
committed
Stop infinit loop on invalid settings css/js file
Don't try to find dirname of false... Signed-off-by: Joas Schilling <[email protected]>
1 parent 770f37a commit afac93b

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

lib/private/Template/CSSResourceLocator.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ public function doFind($style) {
6262
$style = substr($style, strpos($style, '/')+1);
6363
$app_path = \OC_App::getAppPath($app);
6464
$app_url = \OC_App::getAppWebPath($app);
65+
66+
if ($app_path === false && $app_url === false) {
67+
$this->logger->error('Could not find resource {resource} to load', [
68+
'resource' => $app . '/' . $style . '.css',
69+
'app' => 'cssresourceloader',
70+
]);
71+
return;
72+
}
73+
6574
if(!$this->cacheAndAppendScssIfExist($app_path, $style.'.scss', $app)) {
6675
$this->append($app_path, $style.'.css', $app_url);
6776
}

lib/private/Template/JSResourceLocator.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ public function doFind($script) {
7575
$app_path = \OC_App::getAppPath($app);
7676
$app_url = \OC_App::getAppWebPath($app);
7777

78+
if ($app_path === false && $app_url === false) {
79+
$this->logger->error('Could not find resource {resource} to load', [
80+
'resource' => $app . '/' . $script . '.js',
81+
'app' => 'jsresourceloader',
82+
]);
83+
return;
84+
}
85+
7886
// missing translations files fill be ignored
7987
if (strpos($script, 'l10n/') === 0) {
8088
$this->appendIfExist($app_path, $script . '.js', $app_url);

lib/private/Template/ResourceLocator.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ protected function appendIfExist($root, $file, $webRoot = null) {
116116
* @throws ResourceNotFoundException Only thrown when $throw is true and the resource is missing
117117
*/
118118
protected function append($root, $file, $webRoot = null, $throw = true) {
119+
120+
if (!is_string($root) || (!is_string($webRoot) && $webRoot !== null)) {
121+
if ($throw) {
122+
throw new ResourceNotFoundException($file, $webRoot);
123+
}
124+
return;
125+
}
126+
119127
if (!$webRoot) {
120128
$tmpRoot = $root;
121129
/*

0 commit comments

Comments
 (0)