diff options
24 files changed, 347 insertions, 75 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 1f99d561a13..b86b42bdb9a 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -1113,6 +1113,9 @@ OC.Uploader.prototype = _.extend({ }); fileupload.on('fileuploaddrop', function(e, data) { self.trigger('drop', e, data); + if (e.isPropagationStopped()) { + return false; + } }); } diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 9bf25c5904d..79ec8e2d9f9 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -2795,6 +2795,7 @@ var isCreatable = (self.getDirectoryPermissions() & OC.PERMISSION_CREATE) !== 0; if (!isCreatable) { self._showPermissionDeniedNotification(); + e.stopPropagation(); return false; } diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index db86e0037ef..e0965d43143 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -167,7 +167,7 @@ class ViewControllerTest extends TestCase { 'id' => 'sharingin', 'appname' => 'files_sharing', 'script' => 'list.php', - 'order' => 10, + 'order' => 15, 'name' => \OC::$server->getL10N('files_sharing')->t('Shared with you'), 'active' => false, 'icon' => '', @@ -177,7 +177,7 @@ class ViewControllerTest extends TestCase { 'id' => 'sharingout', 'appname' => 'files_sharing', 'script' => 'list.php', - 'order' => 15, + 'order' => 16, 'name' => \OC::$server->getL10N('files_sharing')->t('Shared with others'), 'active' => false, 'icon' => '', @@ -187,7 +187,7 @@ class ViewControllerTest extends TestCase { 'id' => 'sharinglinks', 'appname' => 'files_sharing', 'script' => 'list.php', - 'order' => 20, + 'order' => 17, 'name' => \OC::$server->getL10N('files_sharing')->t('Shared by link', []), 'active' => false, 'icon' => '', diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 41d202e9323..a12c0ff49b6 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -2810,6 +2810,8 @@ describe('OCA.Files.FileList tests', function() { target: $target }, preventDefault: function () { + }, + stopPropagation: function() { } }; uploader.trigger('drop', eventData, data || {}); diff --git a/apps/files_external/3rdparty/.gitignore b/apps/files_external/3rdparty/.gitignore index b56af237c35..a7913dd4308 100644 --- a/apps/files_external/3rdparty/.gitignore +++ b/apps/files_external/3rdparty/.gitignore @@ -2,4 +2,5 @@ example.php icewind/smb/tests icewind/smb/install_libsmbclient.sh icewind/smb/.travis.yml +icewind/smb/.scrutinizer.yml icewind/streams/tests diff --git a/apps/files_external/3rdparty/composer.json b/apps/files_external/3rdparty/composer.json index 2eab8a8f7b4..f1613f0c70b 100644 --- a/apps/files_external/3rdparty/composer.json +++ b/apps/files_external/3rdparty/composer.json @@ -8,7 +8,7 @@ "classmap-authoritative": true }, "require": { - "icewind/smb": "2.0.0", + "icewind/smb": "2.0.2", "icewind/streams": "0.5.2" } } diff --git a/apps/files_external/3rdparty/composer.lock b/apps/files_external/3rdparty/composer.lock index 99ef5f94871..0cf5cabdc19 100644 --- a/apps/files_external/3rdparty/composer.lock +++ b/apps/files_external/3rdparty/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "0bbca3fe2d180fbc5681985bdf6b22e7", + "content-hash": "85f8c3519f909ded38d917d3901f2709", "packages": [ { "name": "icewind/smb", - "version": "v2.0.0", + "version": "v2.0.2", "source": { "type": "git", "url": "https://github.com/icewind1991/SMB.git", - "reference": "95a5ecbaf92617f9800ad7d6070ef31d8ff28c3a" + "reference": "6691355d9314ac3a8cb9ec9446e4c26e8aab09d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/icewind1991/SMB/zipball/95a5ecbaf92617f9800ad7d6070ef31d8ff28c3a", - "reference": "95a5ecbaf92617f9800ad7d6070ef31d8ff28c3a", + "url": "https://api.github.com/repos/icewind1991/SMB/zipball/6691355d9314ac3a8cb9ec9446e4c26e8aab09d0", + "reference": "6691355d9314ac3a8cb9ec9446e4c26e8aab09d0", "shasum": "" }, "require": { @@ -45,7 +45,7 @@ } ], "description": "php wrapper for smbclient and libsmbclient-php", - "time": "2016-12-13T13:56:55+00:00" + "time": "2017-08-16T16:08:57+00:00" }, { "name": "icewind/streams", diff --git a/apps/files_external/3rdparty/composer/ClassLoader.php b/apps/files_external/3rdparty/composer/ClassLoader.php index 4626994fd4d..2c72175e772 100644 --- a/apps/files_external/3rdparty/composer/ClassLoader.php +++ b/apps/files_external/3rdparty/composer/ClassLoader.php @@ -374,9 +374,13 @@ class ClassLoader $first = $class[0]; if (isset($this->prefixLengthsPsr4[$first])) { - foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { - if (0 === strpos($class, $prefix)) { - foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath.'\\'; + if (isset($this->prefixDirsPsr4[$search])) { + foreach ($this->prefixDirsPsr4[$search] as $dir) { + $length = $this->prefixLengthsPsr4[$first][$search]; if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { return $file; } diff --git a/apps/files_external/3rdparty/composer/LICENSE b/apps/files_external/3rdparty/composer/LICENSE index 1a28124886d..f27399a042d 100644 --- a/apps/files_external/3rdparty/composer/LICENSE +++ b/apps/files_external/3rdparty/composer/LICENSE @@ -1,5 +1,5 @@ -Copyright (c) 2016 Nils Adermann, Jordi Boggiano +Copyright (c) Nils Adermann, Jordi Boggiano Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/apps/files_external/3rdparty/composer/autoload_classmap.php b/apps/files_external/3rdparty/composer/autoload_classmap.php index 97f4ce99cda..4c596a44418 100644 --- a/apps/files_external/3rdparty/composer/autoload_classmap.php +++ b/apps/files_external/3rdparty/composer/autoload_classmap.php @@ -36,10 +36,12 @@ return array( 'Icewind\\SMB\\INotifyHandler' => $vendorDir . '/icewind/smb/src/INotifyHandler.php', 'Icewind\\SMB\\IShare' => $vendorDir . '/icewind/smb/src/IShare.php', 'Icewind\\SMB\\NativeFileInfo' => $vendorDir . '/icewind/smb/src/NativeFileInfo.php', + 'Icewind\\SMB\\NativeReadStream' => $vendorDir . '/icewind/smb/src/NativeReadStream.php', 'Icewind\\SMB\\NativeServer' => $vendorDir . '/icewind/smb/src/NativeServer.php', 'Icewind\\SMB\\NativeShare' => $vendorDir . '/icewind/smb/src/NativeShare.php', 'Icewind\\SMB\\NativeState' => $vendorDir . '/icewind/smb/src/NativeState.php', 'Icewind\\SMB\\NativeStream' => $vendorDir . '/icewind/smb/src/NativeStream.php', + 'Icewind\\SMB\\NativeWriteStream' => $vendorDir . '/icewind/smb/src/NativeWriteStream.php', 'Icewind\\SMB\\NotifyHandler' => $vendorDir . '/icewind/smb/src/NotifyHandler.php', 'Icewind\\SMB\\Parser' => $vendorDir . '/icewind/smb/src/Parser.php', 'Icewind\\SMB\\RawConnection' => $vendorDir . '/icewind/smb/src/RawConnection.php', diff --git a/apps/files_external/3rdparty/composer/autoload_static.php b/apps/files_external/3rdparty/composer/autoload_static.php index c1a3a0492d0..459de971c4e 100644 --- a/apps/files_external/3rdparty/composer/autoload_static.php +++ b/apps/files_external/3rdparty/composer/autoload_static.php @@ -66,10 +66,12 @@ class ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3 'Icewind\\SMB\\INotifyHandler' => __DIR__ . '/..' . '/icewind/smb/src/INotifyHandler.php', 'Icewind\\SMB\\IShare' => __DIR__ . '/..' . '/icewind/smb/src/IShare.php', 'Icewind\\SMB\\NativeFileInfo' => __DIR__ . '/..' . '/icewind/smb/src/NativeFileInfo.php', + 'Icewind\\SMB\\NativeReadStream' => __DIR__ . '/..' . '/icewind/smb/src/NativeReadStream.php', 'Icewind\\SMB\\NativeServer' => __DIR__ . '/..' . '/icewind/smb/src/NativeServer.php', 'Icewind\\SMB\\NativeShare' => __DIR__ . '/..' . '/icewind/smb/src/NativeShare.php', 'Icewind\\SMB\\NativeState' => __DIR__ . '/..' . '/icewind/smb/src/NativeState.php', 'Icewind\\SMB\\NativeStream' => __DIR__ . '/..' . '/icewind/smb/src/NativeStream.php', + 'Icewind\\SMB\\NativeWriteStream' => __DIR__ . '/..' . '/icewind/smb/src/NativeWriteStream.php', 'Icewind\\SMB\\NotifyHandler' => __DIR__ . '/..' . '/icewind/smb/src/NotifyHandler.php', 'Icewind\\SMB\\Parser' => __DIR__ . '/..' . '/icewind/smb/src/Parser.php', 'Icewind\\SMB\\RawConnection' => __DIR__ . '/..' . '/icewind/smb/src/RawConnection.php', diff --git a/apps/files_external/3rdparty/composer/installed.json b/apps/files_external/3rdparty/composer/installed.json index 8e065858d02..aafe1591fa8 100644 --- a/apps/files_external/3rdparty/composer/installed.json +++ b/apps/files_external/3rdparty/composer/installed.json @@ -1,33 +1,33 @@ [ { - "name": "icewind/smb", - "version": "v2.0.0", - "version_normalized": "2.0.0.0", + "name": "icewind/streams", + "version": "0.5.2", + "version_normalized": "0.5.2.0", "source": { "type": "git", - "url": "https://github.com/icewind1991/SMB.git", - "reference": "95a5ecbaf92617f9800ad7d6070ef31d8ff28c3a" + "url": "https://github.com/icewind1991/Streams.git", + "reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/icewind1991/SMB/zipball/95a5ecbaf92617f9800ad7d6070ef31d8ff28c3a", - "reference": "95a5ecbaf92617f9800ad7d6070ef31d8ff28c3a", + "url": "https://api.github.com/repos/icewind1991/Streams/zipball/6bfd2fdbd99319f5e010d0a684409189a562cb1e", + "reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e", "shasum": "" }, "require": { - "icewind/streams": ">=0.2.0", - "php": ">=5.4" + "php": ">=5.3" }, "require-dev": { - "phpunit/phpunit": "^4.8" + "phpunit/phpunit": "^4.8", + "satooshi/php-coveralls": "v1.0.0" }, - "time": "2016-12-13T13:56:55+00:00", + "time": "2016-12-02T14:21:23+00:00", "type": "library", - "installation-source": "source", + "installation-source": "dist", "autoload": { "psr-4": { - "Icewind\\SMB\\": "src/", - "Icewind\\SMB\\Test\\": "tests/" + "Icewind\\Streams\\Tests\\": "tests/", + "Icewind\\Streams\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -40,37 +40,37 @@ "email": "icewind@owncloud.com" } ], - "description": "php wrapper for smbclient and libsmbclient-php" + "description": "A set of generic stream wrappers" }, { - "name": "icewind/streams", - "version": "0.5.2", - "version_normalized": "0.5.2.0", + "name": "icewind/smb", + "version": "v2.0.2", + "version_normalized": "2.0.2.0", "source": { "type": "git", - "url": "https://github.com/icewind1991/Streams.git", - "reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e" + "url": "https://github.com/icewind1991/SMB.git", + "reference": "6691355d9314ac3a8cb9ec9446e4c26e8aab09d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/icewind1991/Streams/zipball/6bfd2fdbd99319f5e010d0a684409189a562cb1e", - "reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e", + "url": "https://api.github.com/repos/icewind1991/SMB/zipball/6691355d9314ac3a8cb9ec9446e4c26e8aab09d0", + "reference": "6691355d9314ac3a8cb9ec9446e4c26e8aab09d0", "shasum": "" }, "require": { - "php": ">=5.3" + "icewind/streams": ">=0.2.0", + "php": ">=5.4" }, "require-dev": { - "phpunit/phpunit": "^4.8", - "satooshi/php-coveralls": "v1.0.0" + "phpunit/phpunit": "^4.8" }, - "time": "2016-12-02T14:21:23+00:00", + "time": "2017-08-16T16:08:57+00:00", "type": "library", - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-4": { - "Icewind\\Streams\\Tests\\": "tests/", - "Icewind\\Streams\\": "src/" + "Icewind\\SMB\\": "src/", + "Icewind\\SMB\\Test\\": "tests/" } }, "notification-url": "https://packagist.org/downloads/", @@ -83,6 +83,6 @@ "email": "icewind@owncloud.com" } ], - "description": "A set of generic stream wrappers" + "description": "php wrapper for smbclient and libsmbclient-php" } ] diff --git a/apps/files_external/3rdparty/icewind/smb/src/NativeReadStream.php b/apps/files_external/3rdparty/icewind/smb/src/NativeReadStream.php new file mode 100644 index 00000000000..6fd4f5b7f35 --- /dev/null +++ b/apps/files_external/3rdparty/icewind/smb/src/NativeReadStream.php @@ -0,0 +1,101 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Licensed under the MIT license: + * http://opensource.org/licenses/MIT + */ + +namespace Icewind\SMB; + +/** + * Stream optimized for read only usage + */ +class NativeReadStream extends NativeStream { + const CHUNK_SIZE = 1048576; // 1MB chunks + /** + * @var resource + */ + private $readBuffer = null; + + private $bufferSize = 0; + + private $pos = 0; + + public function stream_open($path, $mode, $options, &$opened_path) { + $this->readBuffer = fopen('php://memory', 'r+'); + + return parent::stream_open($path, $mode, $options, $opened_path); + + } + + /** + * Wrap a stream from libsmbclient-php into a regular php stream + * + * @param \Icewind\SMB\NativeState $state + * @param resource $smbStream + * @param string $mode + * @param string $url + * @return resource + */ + public static function wrap($state, $smbStream, $mode, $url) { + stream_wrapper_register('nativesmb', '\Icewind\SMB\NativeReadStream'); + $context = stream_context_create(array( + 'nativesmb' => array( + 'state' => $state, + 'handle' => $smbStream, + 'url' => $url + ) + )); + $fh = fopen('nativesmb://', $mode, false, $context); + stream_wrapper_unregister('nativesmb'); + return $fh; + } + + public function stream_read($count) { + // php reads 8192 bytes at once + // however due to network latency etc, it's faster to read in larger chunks + // and buffer the result + if (!parent::stream_eof() && $this->bufferSize < $count) { + $remaining = $this->readBuffer; + $this->readBuffer = fopen('php://memory', 'r+'); + $this->bufferSize = 0; + stream_copy_to_stream($remaining, $this->readBuffer); + $this->bufferSize += fwrite($this->readBuffer, parent::stream_read(self::CHUNK_SIZE)); + fseek($this->readBuffer, 0); + } + + $result = fread($this->readBuffer, $count); + $this->bufferSize -= $count; + + $read = strlen($result); + $this->pos += $read; + + return $result; + } + + public function stream_seek($offset, $whence = SEEK_SET) { + $result = parent::stream_seek($offset, $whence); + if ($result) { + $this->readBuffer = fopen('php://memory', 'r+'); + $this->bufferSize = 0; + $this->pos = parent::stream_tell(); + } + return $result; + } + + public function stream_eof() { + return $this->bufferSize <= 0 && parent::stream_eof(); + } + + public function stream_tell() { + return $this->pos; + } + + public function stream_write($data) { + return false; + } + + public function stream_truncate($size) { + return false; + } +} diff --git a/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php b/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php index 7efa34df370..228d9cd7d2e 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php +++ b/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php @@ -174,7 +174,7 @@ class NativeShare extends AbstractShare { $sourceHandle = fopen($source, 'rb'); $targetHandle = $this->state->create($this->buildUrl($target)); - while ($data = fread($sourceHandle, 4096)) { + while ($data = fread($sourceHandle, NativeReadStream::CHUNK_SIZE)) { $this->state->write($targetHandle, $data); } $this->state->close($targetHandle); @@ -214,7 +214,7 @@ class NativeShare extends AbstractShare { throw new InvalidResourceException('Failed opening remote file "' . $source . '" for reading'); } - while ($data = $this->state->read($sourceHandle, 4096)) { + while ($data = $this->state->read($sourceHandle, NativeReadStream::CHUNK_SIZE)) { fwrite($targetHandle, $data); } $this->state->close($sourceHandle); @@ -233,7 +233,7 @@ class NativeShare extends AbstractShare { public function read($source) { $url = $this->buildUrl($source); $handle = $this->state->open($url, 'r'); - return NativeStream::wrap($this->state, $handle, 'r', $url); + return NativeReadStream::wrap($this->state, $handle, 'r', $url); } /** @@ -248,7 +248,7 @@ class NativeShare extends AbstractShare { public function write($source) { $url = $this->buildUrl($source); $handle = $this->state->create($url); - return NativeStream::wrap($this->state, $handle, 'w', $url); + return NativeWriteStream::wrap($this->state, $handle, 'w', $url); } /** diff --git a/apps/files_external/3rdparty/icewind/smb/src/NativeStream.php b/apps/files_external/3rdparty/icewind/smb/src/NativeStream.php index 481395b025a..bce72001b5a 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/NativeStream.php +++ b/apps/files_external/3rdparty/icewind/smb/src/NativeStream.php @@ -20,22 +20,22 @@ class NativeStream implements File { /** * @var \Icewind\SMB\NativeState */ - private $state; + protected $state; /** * @var resource */ - private $handle; + protected $handle; /** * @var bool */ - private $eof = false; + protected $eof = false; /** * @var string */ - private $url; + protected $url; /** * Wrap a stream from libsmbclient-php into a regular php stream @@ -50,9 +50,9 @@ class NativeStream implements File { stream_wrapper_register('nativesmb', '\Icewind\SMB\NativeStream'); $context = stream_context_create(array( 'nativesmb' => array( - 'state' => $state, + 'state' => $state, 'handle' => $smbStream, - 'url' => $url + 'url' => $url ) )); $fh = fopen('nativesmb://', $mode, false, $context); diff --git a/apps/files_external/3rdparty/icewind/smb/src/NativeWriteStream.php b/apps/files_external/3rdparty/icewind/smb/src/NativeWriteStream.php new file mode 100644 index 00000000000..69a270f160f --- /dev/null +++ b/apps/files_external/3rdparty/icewind/smb/src/NativeWriteStream.php @@ -0,0 +1,100 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Licensed under the MIT license: + * http://opensource.org/licenses/MIT + */ + +namespace Icewind\SMB; + +/** + * Stream optimized for write only usage + */ +class NativeWriteStream extends NativeStream { + const CHUNK_SIZE = 1048576; // 1MB chunks + /** + * @var resource + */ + private $writeBuffer = null; + + private $bufferSize = 0; + + private $pos = 0; + + public function stream_open($path, $mode, $options, &$opened_path) { + $this->writeBuffer = fopen('php://memory', 'r+'); + + return parent::stream_open($path, $mode, $options, $opened_path); + + } + + /** + * Wrap a stream from libsmbclient-php into a regular php stream + * + * @param \Icewind\SMB\NativeState $state + * @param resource $smbStream + * @param string $mode + * @param string $url + * @return resource + */ + public static function wrap($state, $smbStream, $mode, $url) { + stream_wrapper_register('nativesmb', '\Icewind\SMB\NativeWriteStream'); + $context = stream_context_create(array( + 'nativesmb' => array( + 'state' => $state, + 'handle' => $smbStream, + 'url' => $url + ) + )); + $fh = fopen('nativesmb://', $mode, false, $context); + stream_wrapper_unregister('nativesmb'); + return $fh; + } + + public function stream_seek($offset, $whence = SEEK_SET) { + $this->flushWrite(); + $result = parent::stream_seek($offset, $whence); + if ($result) { + $this->pos = parent::stream_tell(); + } + return $result; + } + + private function flushWrite() { + rewind($this->writeBuffer); + $this->state->write($this->handle, stream_get_contents($this->writeBuffer)); + $this->writeBuffer = fopen('php://memory', 'r+'); + $this->bufferSize = 0; + } + + public function stream_write($data) { + $written = fwrite($this->writeBuffer, $data); + $this->bufferSize += $written; + $this->pos += $written; + + if ($this->bufferSize >= self::CHUNK_SIZE) { + $this->flushWrite(); + } + + return $written; + } + + public function stream_close() { + $this->flushWrite(); + return parent::stream_close(); + } + + public function stream_tell() { + return $this->pos; + } + + public function stream_read($count) { + return false; + } + + public function stream_truncate($size) { + $this->flushWrite(); + $this->pos = $size; + return parent::stream_truncate($size); + } +} diff --git a/apps/files_external/3rdparty/icewind/smb/src/NotifyHandler.php b/apps/files_external/3rdparty/icewind/smb/src/NotifyHandler.php index 194e848502b..6ad565555bf 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/NotifyHandler.php +++ b/apps/files_external/3rdparty/icewind/smb/src/NotifyHandler.php @@ -59,7 +59,10 @@ class NotifyHandler implements INotifyHandler { public function listen($callback) { if ($this->listening) { $this->connection->read(function ($line) use ($callback) { - return $callback($this->parseChangeLine($line)); + $change = $this->parseChangeLine($line); + if ($change) { + return $callback($change); + } }); } } diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index 30a33aa911d..b89d468f9b0 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -51,7 +51,7 @@ if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') { 'id' => 'sharingin', 'appname' => 'files_sharing', 'script' => 'list.php', - 'order' => 10, + 'order' => 15, 'name' => $l->t('Shared with you'), ]; }); @@ -63,7 +63,7 @@ if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') { 'id' => 'sharingout', 'appname' => 'files_sharing', 'script' => 'list.php', - 'order' => 15, + 'order' => 16, 'name' => $l->t('Shared with others'), ]; }); @@ -76,7 +76,7 @@ if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') { 'id' => 'sharinglinks', 'appname' => 'files_sharing', 'script' => 'list.php', - 'order' => 20, + 'order' => 17, 'name' => $l->t('Shared by link'), ]; }); diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js index f1fc71c6ce2..8d1273f1872 100644 --- a/apps/files_sharing/js/files_drop.js +++ b/apps/files_sharing/js/files_drop.js @@ -14,7 +14,7 @@ '{{#if isUploading}}' + '<span class="icon-loading-small"></span> {{name}}' + '{{else}}' + - '<img src="' + OC.imagePath('core', 'actions/error.svg') + '"/> {{name}}' + + '<img src="{{iconSrc}}"/> {{name}}' + '{{/if}}' + '</li>'; var Drop = { @@ -63,17 +63,16 @@ $('#drop-upload-done-indicator').addClass('hidden'); $('#drop-upload-progress-indicator').removeClass('hidden'); - _.each(data['files'], function(file) { - $('#public-upload ul').append(output({isUploading: true, name: escapeHTML(file.name)})); - $('[data-toggle="tooltip"]').tooltip(); - data.submit(); - }); + + $('#public-upload ul').append(output({isUploading: true, name: data.files[0].name})); + $('[data-toggle="tooltip"]').tooltip(); + data.submit(); return true; }, - setFileIcon: function (fileName,fileIcon) { - $('#public-upload ul li[data-name="' + fileName + '"]').html(fileIcon); + updateFileItem: function (fileName, fileItem) { + $('#public-upload ul li[data-name="' + fileName + '"]').replaceWith(fileItem); $('[data-toggle="tooltip"]').tooltip(); }, @@ -83,14 +82,12 @@ e.preventDefault(); }); var output = this.template(); - var fileName = undefined; $('#public-upload').fileupload({ type: 'PUT', dropZone: $('#public-upload'), sequentialUploads: true, add: function(e, data) { Drop.addFileToUpload(e, data); - fileName = escapeHTML(data.files[0].name); //we return true to keep trying to upload next file even //if addFileToUpload did not like the privious one return true; @@ -98,17 +95,18 @@ done: function(e, data) { // Created var mimeTypeUrl = OC.MimeType.getIconUrl(data.files[0].type); - var fileIcon = '<img src="' + escapeHTML(mimeTypeUrl) + '"/> ' + fileName; - Drop.setFileIcon(fileName,fileIcon); + var fileItem = output({isUploading: false, iconSrc: mimeTypeUrl, name: data.files[0].name}); + Drop.updateFileItem(data.files[0].name, fileItem); }, - fail: function(e, data, errorThrown) { + fail: function(e, data) { OC.Notification.showTemporary(OC.L10N.translate( 'files_sharing', 'Could not upload "{filename}"', - {filename: fileName} + {filename: data.files[0].name} )); - var fileIcon = output({isUploading: false, name: fileName}); - Drop.setFileIcon(fileName,fileIcon); + var errorIconSrc = OC.imagePath('core', 'actions/error.svg'); + var fileItem = output({isUploading: false, iconSrc: errorIconSrc, name: data.files[0].name}); + Drop.updateFileItem(data.files[0].name, fileItem); }, progressall: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); diff --git a/core/Controller/TwoFactorChallengeController.php b/core/Controller/TwoFactorChallengeController.php index 9f379ad30d7..9c22da8ae09 100644 --- a/core/Controller/TwoFactorChallengeController.php +++ b/core/Controller/TwoFactorChallengeController.php @@ -1,4 +1,5 @@ <?php + /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -29,6 +30,7 @@ use OC_Util; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\TemplateResponse; +use OCP\Authentication\TwoFactorAuth\IProvidesCustomCSP; use OCP\Authentication\TwoFactorAuth\TwoFactorException; use OCP\IRequest; use OCP\ISession; @@ -135,7 +137,11 @@ class TwoFactorChallengeController extends Controller { 'redirect_url' => $redirect_url, 'template' => $tmpl->fetchPage(), ]; - return new TemplateResponse($this->appName, 'twofactorshowchallenge', $data, 'guest'); + $response = new TemplateResponse($this->appName, 'twofactorshowchallenge', $data, 'guest'); + if ($provider instanceof IProvidesCustomCSP) { + $response->setContentSecurityPolicy($provider->getCSP()); + } + return $response; } /** diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index e99f7efd57a..4cef6a65388 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -60,6 +60,7 @@ return array( 'OCP\\Authentication\\LoginCredentials\\ICredentials' => $baseDir . '/lib/public/Authentication/LoginCredentials/ICredentials.php', 'OCP\\Authentication\\LoginCredentials\\IStore' => $baseDir . '/lib/public/Authentication/LoginCredentials/IStore.php', 'OCP\\Authentication\\TwoFactorAuth\\IProvider' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/IProvider.php', + 'OCP\\Authentication\\TwoFactorAuth\\IProvidesCustomCSP' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/IProvidesCustomCSP.php', 'OCP\\Authentication\\TwoFactorAuth\\TwoFactorException' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/TwoFactorException.php', 'OCP\\AutoloadNotAllowedException' => $baseDir . '/lib/public/AutoloadNotAllowedException.php', 'OCP\\BackgroundJob' => $baseDir . '/lib/public/BackgroundJob.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 92260f83cb9..50ab55365b4 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -90,6 +90,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Authentication\\LoginCredentials\\ICredentials' => __DIR__ . '/../../..' . '/lib/public/Authentication/LoginCredentials/ICredentials.php', 'OCP\\Authentication\\LoginCredentials\\IStore' => __DIR__ . '/../../..' . '/lib/public/Authentication/LoginCredentials/IStore.php', 'OCP\\Authentication\\TwoFactorAuth\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/IProvider.php', + 'OCP\\Authentication\\TwoFactorAuth\\IProvidesCustomCSP' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/IProvidesCustomCSP.php', 'OCP\\Authentication\\TwoFactorAuth\\TwoFactorException' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/TwoFactorException.php', 'OCP\\AutoloadNotAllowedException' => __DIR__ . '/../../..' . '/lib/public/AutoloadNotAllowedException.php', 'OCP\\BackgroundJob' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob.php', diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index ad78a0db745..d722b5c923a 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1159,6 +1159,15 @@ class Manager implements IManager { } } + if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_CIRCLE)) { + try { + $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_CIRCLE); + $share = $provider->getShareByToken($token); + } catch (ProviderException $e) { + } catch (ShareNotFound $e) { + } + } + if ($share === null) { throw new ShareNotFound($this->l->t('The requested share does not exist anymore')); } diff --git a/lib/public/Authentication/TwoFactorAuth/IProvidesCustomCSP.php b/lib/public/Authentication/TwoFactorAuth/IProvidesCustomCSP.php new file mode 100644 index 00000000000..2c1dc001c1a --- /dev/null +++ b/lib/public/Authentication/TwoFactorAuth/IProvidesCustomCSP.php @@ -0,0 +1,38 @@ +<?php + +/** + * @author Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Authentication\TwoFactorAuth; + +use OCP\AppFramework\Http\ContentSecurityPolicy; + +/** + * @since 13.0.0 + */ +interface IProvidesCustomCSP { + + /** + * @return ContentSecurityPolicy + * + * @since 13.0.0 + */ + public function getCSP(); +} |