summaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Stream/Encryption.php
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-12-03 11:03:17 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-12-29 09:07:36 +0100
commit73c7d0dc8156703341733b9c39c69d05263173da (patch)
treeb960b9acb15d29aa5dded5aaedbe07eda651ecc3 /lib/private/Files/Stream/Encryption.php
parent083f3d23737b99fafec87c64df99e9c09cde71c7 (diff)
downloadnextcloud-server-73c7d0dc8156703341733b9c39c69d05263173da.tar.gz
nextcloud-server-73c7d0dc8156703341733b9c39c69d05263173da.zip
Bump icewind/streams from 0.7.1 to 0.7.2
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/Files/Stream/Encryption.php')
-rw-r--r--lib/private/Files/Stream/Encryption.php35
1 files changed, 27 insertions, 8 deletions
diff --git a/lib/private/Files/Stream/Encryption.php b/lib/private/Files/Stream/Encryption.php
index 577d1554101..16d2ca3ce97 100644
--- a/lib/private/Files/Stream/Encryption.php
+++ b/lib/private/Files/Stream/Encryption.php
@@ -34,6 +34,8 @@ namespace OC\Files\Stream;
use Icewind\Streams\Wrapper;
use OC\Encryption\Exceptions\EncryptionHeaderKeyExistsException;
+use function is_array;
+use function stream_context_create;
class Encryption extends Wrapper {
@@ -190,17 +192,22 @@ class Encryption extends Wrapper {
/**
* add stream wrapper
*
- * @param resource $source
+ * @param resource|int $source
+ * @param resource|array $context
+ * @param string|null $protocol
+ * @param string|null $class
* @param string $mode
- * @param resource $context
- * @param string $protocol
- * @param string $class
* @return resource
* @throws \BadMethodCallException
*/
- protected static function wrapSource($source, $context, $protocol, $class, $mode = 'r+') {
+ protected static function wrapSource($source, $context = [], $protocol = null, $class = null, $mode = 'r+') {
try {
+ if ($protocol === null) {
+ $protocol = self::getProtocol($class);
+ }
+
stream_wrapper_register($protocol, $class);
+ $context = self::buildContext($protocol, $context, $source);
if (self::isDirectoryHandle($source)) {
$wrapped = opendir($protocol . '://', $context);
} else {
@@ -215,13 +222,25 @@ class Encryption extends Wrapper {
}
/**
+ * @todo this is a copy of \Icewind\Streams\WrapperHandler::buildContext -> combine to one shared method?
+ */
+ private static function buildContext($protocol, $context, $source) {
+ if (is_array($context)) {
+ $context['source'] = $source;
+ return stream_context_create([$protocol => $context]);
+ }
+
+ return $context;
+ }
+
+ /**
* Load the source from the stream context and return the context options
*
- * @param string $name
+ * @param string|null $name
* @return array
* @throws \BadMethodCallException
*/
- protected function loadContext($name) {
+ protected function loadContext($name = null) {
$context = parent::loadContext($name);
foreach ($this->expectedContextProperties as $property) {
@@ -314,7 +333,7 @@ class Encryption extends Wrapper {
}
return $result;
}
-
+
/**
* stream_read_block
*