summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php5
-rw-r--r--lib/private/AppFramework/OCS/BaseResponse.php3
-rw-r--r--lib/private/AppFramework/Utility/SimpleContainer.php11
-rw-r--r--lib/private/Log.php2
-rw-r--r--lib/private/legacy/util.php17
5 files changed, 34 insertions, 4 deletions
diff --git a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
index 3bfef2df025..5e253d0954a 100644
--- a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
+++ b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
@@ -37,6 +37,7 @@ use OC\AppFramework\Middleware\Security\Exceptions\StrictCookieMissingException;
use OC\AppFramework\Utility\ControllerMethodReflector;
use OC\Security\CSP\ContentSecurityPolicyManager;
use OCP\AppFramework\Http\ContentSecurityPolicy;
+use OCP\AppFramework\Http\EmptyContentSecurityPolicy;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Middleware;
@@ -182,6 +183,10 @@ class SecurityMiddleware extends Middleware {
public function afterController($controller, $methodName, Response $response) {
$policy = !is_null($response->getContentSecurityPolicy()) ? $response->getContentSecurityPolicy() : new ContentSecurityPolicy();
+ if (get_class($policy) === EmptyContentSecurityPolicy::class) {
+ return $response;
+ }
+
$defaultPolicy = $this->contentSecurityPolicyManager->getDefaultPolicy();
$defaultPolicy = $this->contentSecurityPolicyManager->mergePolicies($defaultPolicy, $policy);
diff --git a/lib/private/AppFramework/OCS/BaseResponse.php b/lib/private/AppFramework/OCS/BaseResponse.php
index fa22498ac0f..59b8660a382 100644
--- a/lib/private/AppFramework/OCS/BaseResponse.php
+++ b/lib/private/AppFramework/OCS/BaseResponse.php
@@ -23,6 +23,7 @@
namespace OC\AppFramework\OCS;
use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\Http\EmptyContentSecurityPolicy;
use OCP\AppFramework\Http\Response;
abstract class BaseResponse extends Response {
@@ -67,7 +68,7 @@ abstract class BaseResponse extends Response {
$this->setETag($dataResponse->getETag());
$this->setLastModified($dataResponse->getLastModified());
$this->setCookies($dataResponse->getCookies());
- $this->setContentSecurityPolicy($dataResponse->getContentSecurityPolicy());
+ $this->setContentSecurityPolicy(new EmptyContentSecurityPolicy());
if ($format === 'json') {
$this->addHeader(
diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php
index ff58e86c804..8d5bceb0b87 100644
--- a/lib/private/AppFramework/Utility/SimpleContainer.php
+++ b/lib/private/AppFramework/Utility/SimpleContainer.php
@@ -62,7 +62,16 @@ class SimpleContainer extends Container implements IContainer {
$resolveName = $parameterClass->name;
}
- $parameters[] = $this->query($resolveName);
+ try {
+ $parameters[] = $this->query($resolveName);
+ } catch (\Exception $e) {
+ // Service not found, use the default value when available
+ if ($parameter->isDefaultValueAvailable()) {
+ $parameters[] = $parameter->getDefaultValue();
+ } else {
+ throw $e;
+ }
+ }
}
return $class->newInstanceArgs($parameters);
}
diff --git a/lib/private/Log.php b/lib/private/Log.php
index 3e0734965b0..b76cb4f8c28 100644
--- a/lib/private/Log.php
+++ b/lib/private/Log.php
@@ -233,7 +233,7 @@ class Log implements ILogger {
* @return void
*/
public function log($level, $message, array $context = array()) {
- $minLevel = min($this->config->getValue('loglevel', Util::WARN), Util::ERROR);
+ $minLevel = min($this->config->getValue('loglevel', Util::WARN), Util::FATAL);
$logCondition = $this->config->getValue('log.condition', []);
array_walk($context, [$this->normalizer, 'format']);
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php
index 04dcb8fc896..cb52949779f 100644
--- a/lib/private/legacy/util.php
+++ b/lib/private/legacy/util.php
@@ -336,7 +336,16 @@ class OC_Util {
* @return void
*/
public static function copyr($source, \OCP\Files\Folder $target) {
+ $logger = \OC::$server->getLogger();
+
+ // Verify if folder exists
$dir = opendir($source);
+ if($dir === false) {
+ $logger->error(sprintf('Could not opendir "%s"', $source), ['app' => 'core']);
+ return;
+ }
+
+ // Copy the files
while (false !== ($file = readdir($dir))) {
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
if (is_dir($source . '/' . $file)) {
@@ -344,7 +353,13 @@ class OC_Util {
self::copyr($source . '/' . $file, $child);
} else {
$child = $target->newFile($file);
- stream_copy_to_stream(fopen($source . '/' . $file,'r'), $child->fopen('w'));
+ $sourceStream = fopen($source . '/' . $file, 'r');
+ if($sourceStream === false) {
+ $logger->error(sprintf('Could not fopen "%s"', $source . '/' . $file), ['app' => 'core']);
+ closedir($dir);
+ return;
+ }
+ stream_copy_to_stream($sourceStream, $child->fopen('w'));
}
}
}