diff options
158 files changed, 517 insertions, 603 deletions
@@ -182,7 +182,8 @@ Jesús Macias <jmacias@solidgear.es> Jesus Macias <jmacias@full-on-net.com> jknockaert <jasper@knockaert.nl> Joan <aseques@gmail.com> Joar Wandborg <git@wandborg.com> -Joas Schilling <nickvergessen@owncloud.com> Joas Schilling <nickvergessen@gmx.de> +Joas Schilling <coding@schilljs.com> Joas Schilling <nickvergessen@gmx.de> +Joas Schilling <coding@schilljs.com> Joas Schilling <nickvergessen@owncloud.com> joel hansson <joel.hansson@gmail.com> Johan Björk <johanimon@gmail.com> Johannes Twittmann <github.com@deryo.de> diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index ce494082976..565ad0ec663 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1079,22 +1079,27 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription 'lastmodified' => time(), ]; - foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) { - if (isset($properties[$xmlName])) { + $propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments']; - $values[$dbName] = $properties[$xmlName]; - $fieldNames[] = $dbName; + foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) { + if (array_key_exists($xmlName, $properties)) { + $values[$dbName] = $properties[$xmlName]; + if (in_array($dbName, $propertiesBoolean)) { + $values[$dbName] = true; + } } } + $valuesToInsert = array(); + $query = $this->db->getQueryBuilder(); + + foreach (array_keys($values) as $name) { + $valuesToInsert[$name] = $query->createNamedParameter($values[$name]); + } + $query->insert('calendarsubscriptions') - ->values([ - 'principaluri' => $query->createNamedParameter($values['principaluri']), - 'uri' => $query->createNamedParameter($values['uri']), - 'source' => $query->createNamedParameter($values['source']), - 'lastmodified' => $query->createNamedParameter($values['lastmodified']), - ]) + ->values($valuesToInsert) ->execute(); return $this->db->lastInsertId('*PREFIX*calendarsubscriptions'); diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index 977bdf15c8e..baa8540c43c 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -333,15 +333,20 @@ EOD; public function testSubscriptions() { $id = $this->backend->createSubscription(self::UNIT_TEST_USER, 'Subscription', [ - '{http://calendarserver.org/ns/}source' => new Href('test-source') + '{http://calendarserver.org/ns/}source' => new Href('test-source'), + '{http://apple.com/ns/ical/}calendar-color' => '#1C4587', + '{http://calendarserver.org/ns/}subscribed-strip-todos' => '' ]); $subscriptions = $this->backend->getSubscriptionsForUser(self::UNIT_TEST_USER); $this->assertEquals(1, count($subscriptions)); + $this->assertEquals('#1C4587', $subscriptions[0]['{http://apple.com/ns/ical/}calendar-color']); + $this->assertEquals(true, $subscriptions[0]['{http://calendarserver.org/ns/}subscribed-strip-todos']); $this->assertEquals($id, $subscriptions[0]['id']); $patch = new PropPatch([ '{DAV:}displayname' => 'Unit test', + '{http://apple.com/ns/ical/}calendar-color' => '#ac0606', ]); $this->backend->updateSubscription($id, $patch); $patch->commit(); @@ -350,6 +355,7 @@ EOD; $this->assertEquals(1, count($subscriptions)); $this->assertEquals($id, $subscriptions[0]['id']); $this->assertEquals('Unit test', $subscriptions[0]['{DAV:}displayname']); + $this->assertEquals('#ac0606', $subscriptions[0]['{http://apple.com/ns/ical/}calendar-color']); $this->backend->deleteSubscription($id); $subscriptions = $this->backend->getSubscriptionsForUser(self::UNIT_TEST_USER); diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 40e2e8a472f..1ea31f2dbc0 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -217,28 +217,32 @@ class FederatedShareProvider implements IShareProvider { $share->getPermissions(), $token ); - $sharedByFederatedId = $share->getSharedBy(); - if ($this->userManager->userExists($sharedByFederatedId)) { - $sharedByFederatedId = $sharedByFederatedId . '@' . $this->addressHandler->generateRemoteURL(); - } - $send = $this->notifications->sendRemoteShare( - $token, - $share->getSharedWith(), - $share->getNode()->getName(), - $shareId, - $share->getShareOwner(), - $share->getShareOwner() . '@' . $this->addressHandler->generateRemoteURL(), - $share->getSharedBy(), - $sharedByFederatedId - ); - if ($send === false) { - $data = $this->getRawShare($shareId); - $share = $this->createShareObject($data); - $this->removeShareFromTable($share); - $message_t = $this->l->t('Sharing %s failed, could not find %s, maybe the server is currently unreachable.', - [$share->getNode()->getName(), $share->getSharedWith()]); - throw new \Exception($message_t); + try { + $sharedByFederatedId = $share->getSharedBy(); + if ($this->userManager->userExists($sharedByFederatedId)) { + $sharedByFederatedId = $sharedByFederatedId . '@' . $this->addressHandler->generateRemoteURL(); + } + $send = $this->notifications->sendRemoteShare( + $token, + $share->getSharedWith(), + $share->getNode()->getName(), + $shareId, + $share->getShareOwner(), + $share->getShareOwner() . '@' . $this->addressHandler->generateRemoteURL(), + $share->getSharedBy(), + $sharedByFederatedId + ); + + if ($send === false) { + $message_t = $this->l->t('Sharing %s failed, could not find %s, maybe the server is currently unreachable.', + [$share->getNode()->getName(), $share->getSharedWith()]); + throw new \Exception($message_t); + } + } catch (\Exception $e) { + $this->logger->error('Failed to notify remote server of federated share, removing share (' . $e->getMessage() . ')'); + $this->removeShareFromTableById($shareId); + throw $e; } return $shareId; @@ -526,13 +530,22 @@ class FederatedShareProvider implements IShareProvider { * @param IShare $share */ public function removeShareFromTable(IShare $share) { + $this->removeShareFromTableById($share->getId()); + } + + /** + * remove share from table + * + * @param string $shareId + */ + private function removeShareFromTableById($shareId) { $qb = $this->dbConnection->getQueryBuilder(); $qb->delete('share') - ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))); + ->where($qb->expr()->eq('id', $qb->createNamedParameter($shareId))); $qb->execute(); $qb->delete('federated_reshares') - ->where($qb->expr()->eq('share_id', $qb->createNamedParameter($share->getId()))); + ->where($qb->expr()->eq('share_id', $qb->createNamedParameter($shareId))); $qb->execute(); } diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 6792e534cc6..8c5efdab7b0 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -217,10 +217,6 @@ class FederatedShareProviderTest extends \Test\TestCase { 'sharedBy@http://localhost/' )->willReturn(false); - $this->rootFolder->expects($this->once()) - ->method('getUserFolder') - ->with('shareOwner') - ->will($this->returnSelf()); $this->rootFolder->method('getById') ->with('42') ->willReturn([$node]); @@ -244,6 +240,62 @@ class FederatedShareProviderTest extends \Test\TestCase { $this->assertFalse($data); } + public function testCreateException() { + $share = $this->shareManager->newShare(); + + $node = $this->getMock('\OCP\Files\File'); + $node->method('getId')->willReturn(42); + $node->method('getName')->willReturn('myFile'); + + $share->setSharedWith('user@server.com') + ->setSharedBy('sharedBy') + ->setShareOwner('shareOwner') + ->setPermissions(19) + ->setNode($node); + + $this->tokenHandler->method('generateToken')->willReturn('token'); + + $this->addressHandler->expects($this->any())->method('generateRemoteURL') + ->willReturn('http://localhost/'); + $this->addressHandler->expects($this->any())->method('splitUserRemote') + ->willReturn(['user', 'server.com']); + + $this->notifications->expects($this->once()) + ->method('sendRemoteShare') + ->with( + $this->equalTo('token'), + $this->equalTo('user@server.com'), + $this->equalTo('myFile'), + $this->anything(), + 'shareOwner', + 'shareOwner@http://localhost/', + 'sharedBy', + 'sharedBy@http://localhost/' + )->willThrowException(new \Exception('dummy')); + + $this->rootFolder->method('getById') + ->with('42') + ->willReturn([$node]); + + try { + $share = $this->provider->create($share); + $this->fail(); + } catch (\Exception $e) { + $this->assertEquals('dummy', $e->getMessage()); + } + + $qb = $this->connection->getQueryBuilder(); + $stmt = $qb->select('*') + ->from('share') + ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) + ->execute(); + + $data = $stmt->fetch(); + $stmt->closeCursor(); + + $this->assertFalse($data); + } + public function testCreateShareWithSelf() { $share = $this->shareManager->newShare(); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 24a6f4ec6e2..f0b16a57886 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -513,7 +513,7 @@ * Event handler for when the URL changed */ _onUrlChanged: function(e) { - if (e && e.dir) { + if (e && _.isString(e.dir)) { this.changeDirectory(e.dir, false, true); } }, @@ -1397,6 +1397,16 @@ return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/'); }, + _isValidPath: function(path) { + var sections = path.split('/'); + for (var i = 0; i < sections.length; i++) { + if (sections[i] === '..') { + return false; + } + } + return true; + }, + /** * Sets the current directory name and updates the breadcrumb. * @param targetDir directory to display @@ -1404,7 +1414,11 @@ * @param {string} [fileId] file id */ _setCurrentDir: function(targetDir, changeUrl, fileId) { - targetDir = targetDir.replace(/\\/g, '/').replace(/\/\.\.\//g, '/'); + targetDir = targetDir.replace(/\\/g, '/'); + if (!this._isValidPath(targetDir)) { + targetDir = '/'; + changeUrl = true; + } var previousDir = this.getCurrentDirectory(), baseDir = OC.basename(targetDir); @@ -1415,6 +1429,9 @@ this.setPageTitle(); } + if (targetDir.length > 0 && targetDir[0] !== '/') { + targetDir = '/' + targetDir; + } this._currentDirectory = targetDir; // legacy stuff diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 453f1cafcaf..98511fd3d64 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -1334,13 +1334,32 @@ describe('OCA.Files.FileList tests', function() { fileList.changeDirectory('/another\\subdir'); expect(fileList.getCurrentDirectory()).toEqual('/another/subdir'); }); - it('converts backslashes to slashes and removes traversals when calling changeDirectory()', function() { - fileList.changeDirectory('/another\\subdir/../foo\\../bar\\..\\file/..\\folder/../'); - expect(fileList.getCurrentDirectory()).toEqual('/another/subdir/foo/bar/file/folder/'); + it('switches to root dir when current directory is invalid', function() { + _.each([ + '..', + '/..', + '../', + '/../', + '/../abc', + '/abc/..', + '/abc/../', + '/../abc/', + '/another\\subdir/../foo\\../bar\\..\\file/..\\folder/../' + ], function(path) { + fileList.changeDirectory(path); + expect(fileList.getCurrentDirectory()).toEqual('/'); + }); }); - it('does not convert folders with a ".." in the name', function() { - fileList.changeDirectory('/abc../def'); - expect(fileList.getCurrentDirectory()).toEqual('/abc../def'); + it('allows paths with dotdot at the beginning or end', function() { + _.each([ + '/..abc', + '/def..', + '/...', + '/abc../def' + ], function(path) { + fileList.changeDirectory(path); + expect(fileList.getCurrentDirectory()).toEqual(path); + }); }); it('switches to root dir when current directory does not exist', function() { fileList.changeDirectory('/unexist'); @@ -1404,6 +1423,12 @@ describe('OCA.Files.FileList tests', function() { setDirSpy.restore(); getFolderContentsStub.restore(); }); + it('prepends a slash to directory if none was given', function() { + fileList.changeDirectory(''); + expect(fileList.getCurrentDirectory()).toEqual('/'); + fileList.changeDirectory('noslash'); + expect(fileList.getCurrentDirectory()).toEqual('/noslash'); + }); }); describe('breadcrumb events', function() { var deferredList; diff --git a/apps/files_external/lib/Command/Backends.php b/apps/files_external/lib/Command/Backends.php index 260ea210397..d1da6db3f6a 100644 --- a/apps/files_external/lib/Command/Backends.php +++ b/apps/files_external/lib/Command/Backends.php @@ -98,15 +98,30 @@ class Backends extends Base { $result = [ 'name' => $data['name'], 'identifier' => $data['identifier'], - 'configuration' => array_map(function (DefinitionParameter $parameter) { - return $parameter->getTypeName(); - }, $data['configuration']) + 'configuration' => $this->formatConfiguration($data['configuration']) ]; if ($backend instanceof Backend) { $result['storage_class'] = $backend->getStorageClass(); $authBackends = $this->backendService->getAuthMechanismsByScheme(array_keys($backend->getAuthSchemes())); $result['supported_authentication_backends'] = array_keys($authBackends); + $authConfig = array_map(function (AuthMechanism $auth) { + return $this->serializeAuthBackend($auth)['configuration']; + }, $authBackends); + $result['authentication_configuration'] = array_combine(array_keys($authBackends), $authConfig); } return $result; } + + /** + * @param DefinitionParameter[] $parameters + * @return string[] + */ + private function formatConfiguration(array $parameters) { + $configuration = array_filter($parameters, function (DefinitionParameter $parameter) { + return $parameter->getType() !== DefinitionParameter::VALUE_HIDDEN; + }); + return array_map(function (DefinitionParameter $parameter) { + return $parameter->getTypeName(); + }, $configuration); + } } diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js index da0f957ed99..dccd6027b02 100644 --- a/apps/files_sharing/js/sharedfilelist.js +++ b/apps/files_sharing/js/sharedfilelist.js @@ -79,6 +79,42 @@ var permission = parseInt($tr.attr('data-permissions')) | OC.PERMISSION_DELETE; $tr.attr('data-permissions', permission); } + + // add row with expiration date for link only shares - influenced by _createRow of filelist + if (this._linksOnly) { + var expirationTimestamp = 0; + if(fileData.shares[0].expiration !== null) { + expirationTimestamp = moment(fileData.shares[0].expiration).valueOf(); + } + $tr.attr('data-expiration', expirationTimestamp); + + // date column (1000 milliseconds to seconds, 60 seconds, 60 minutes, 24 hours) + // difference in days multiplied by 5 - brightest shade for expiry dates in more than 32 days (160/5) + var modifiedColor = Math.round((expirationTimestamp - (new Date()).getTime()) / 1000 / 60 / 60 / 24 * 5); + // ensure that the brightest color is still readable + if (modifiedColor >= 160) { + modifiedColor = 160; + } + + if (expirationTimestamp > 0) { + formatted = OC.Util.formatDate(expirationTimestamp); + text = OC.Util.relativeModifiedDate(expirationTimestamp); + } else { + formatted = t('files_sharing', 'No expiration date set'); + text = ''; + modifiedColor = 160; + } + td = $('<td></td>').attr({"class": "date"}); + td.append($('<span></span>').attr({ + "class": "modified", + "title": formatted, + "style": 'color:rgb(' + modifiedColor + ',' + modifiedColor + ',' + modifiedColor + ')' + }).text(text) + .tooltip({placement: 'top'}) + ); + + $tr.append(td); + } return $tr; }, @@ -98,6 +134,11 @@ // root has special permissions this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty); this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty); + + // hide expiration date header for non link only shares + if (!this._linksOnly) { + this.$el.find('th.column-expiration').addClass('hidden'); + } } else { OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments); @@ -249,6 +290,7 @@ type: share.share_type, target: share.share_with, stime: share.stime * 1000, + expiration: share.expiration, }; if (self._sharedWithUser) { file.shareOwner = share.displayname_owner; diff --git a/apps/files_sharing/templates/list.php b/apps/files_sharing/templates/list.php index fa0365c749c..f59cb7653d8 100644 --- a/apps/files_sharing/templates/list.php +++ b/apps/files_sharing/templates/list.php @@ -22,6 +22,9 @@ <th id="headerDate" class="hidden column-mtime"> <a id="modified" class="columntitle" data-sort="mtime"><span><?php p($l->t( 'Share time' )); ?></span><span class="sort-indicator"></span></a> </th> + <th class="hidden column-expiration"> + <a class="columntitle"><span><?php p($l->t( 'Expiration date' )); ?></span></a> + </th> </tr> </thead> <tbody id="fileList"> diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php index f69098cde7b..90d9f0a8567 100644 --- a/apps/files_sharing/tests/MountProviderTest.php +++ b/apps/files_sharing/tests/MountProviderTest.php @@ -30,6 +30,9 @@ use OCP\Share\IShare; use OCP\Share\IManager; use OCP\Files\Mount\IMountPoint; +/** + * @group DB + */ class MountProviderTest extends \Test\TestCase { /** @var MountProvider */ diff --git a/apps/files_sharing/tests/js/sharedfilelistSpec.js b/apps/files_sharing/tests/js/sharedfilelistSpec.js index 0b0676a19e6..f177b61c78a 100644 --- a/apps/files_sharing/tests/js/sharedfilelistSpec.js +++ b/apps/files_sharing/tests/js/sharedfilelistSpec.js @@ -38,6 +38,9 @@ describe('OCA.Sharing.FileList tests', function() { '<th class="hidden column-mtime">' + '<a class="columntitle" data-sort="mtime"><span class="sort-indicator"></span></a>' + '</th>' + + '<th class="column-expiration">' + + '<a class="columntitle"><span>Expiration date</span></a>' + + '</th>' + '</tr></thead>' + '<tbody id="fileList"></tbody>' + '<tfoot></tfoot>' + @@ -512,6 +515,9 @@ describe('OCA.Sharing.FileList tests', function() { fileList.reload(); + var expirationDateInADay = moment() + .add(1, 'days').format('YYYY-MM-DD HH:mm:ss'); + /* jshint camelcase: false */ ocsResponse = { ocs: { @@ -528,12 +534,28 @@ describe('OCA.Sharing.FileList tests', function() { path: '/local path/local name.txt', permissions: 1, stime: 11111, + expiration: null, share_type: OC.Share.SHARE_TYPE_LINK, share_with: null, token: 'abc', mimetype: 'text/plain', uid_owner: 'user1', displayname_owner: 'User One' + },{ + id: 8, + item_type: 'file', + item_source: 50, + file_source: 50, + path: '/local path2/local name2.txt', + permissions: 1, + stime: 11112, + expiration: expirationDateInADay, + share_type: OC.Share.SHARE_TYPE_LINK, + share_with: null, + token: 'abcd', + mimetype: 'text/plain2', + uid_owner: 'user2', + displayname_owner: 'User One2' }] } }; @@ -570,10 +592,10 @@ describe('OCA.Sharing.FileList tests', function() { JSON.stringify(ocsResponse) ); - // only renders the link share entry + // only renders the link share entries var $rows = fileList.$el.find('tbody tr'); var $tr = $rows.eq(0); - expect($rows.length).toEqual(1); + expect($rows.length).toEqual(2); expect($tr.attr('data-id')).toEqual('49'); expect($tr.attr('data-type')).toEqual('file'); expect($tr.attr('data-file')).toEqual('local name.txt'); @@ -588,8 +610,17 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.find('a.name').attr('href')).toEqual( OC.webroot + '/remote.php/webdav/local%20path/local%20name.txt' ); + expect($tr.attr('data-expiration')).toEqual('0'); + expect($tr.find('td:last-child span').text()).toEqual(''); expect($tr.find('.nametext').text().trim()).toEqual('local name.txt'); + + // change to next row + $tr = $rows.eq(1); + expect($tr.attr('data-id')).toEqual('50'); + expect($tr.attr('data-file')).toEqual('local name2.txt'); + expect($tr.attr('data-expiration')).not.toEqual('0'); + expect($tr.find('td:last-child span').text()).toEqual('in a day'); }); it('does not show virtual token recipient as recipient when password was set', function() { /* jshint camelcase: false */ @@ -613,7 +644,7 @@ describe('OCA.Sharing.FileList tests', function() { // only renders the link share entry var $rows = fileList.$el.find('tbody tr'); var $tr = $rows.eq(0); - expect($rows.length).toEqual(1); + expect($rows.length).toEqual(2); expect($tr.attr('data-id')).toEqual('49'); expect($tr.attr('data-type')).toEqual('file'); expect($tr.attr('data-file')).toEqual('local name.txt'); diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index f0cd9d65310..cd4830d5469 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -645,7 +645,7 @@ class Storage { //distance between two version too small, mark to delete $toDelete[$key] = $version['path'] . '.v' . $version['version']; $size += $version['size']; - \OCP\Util::writeLog('files_versions', 'Mark to expire '. $version['path'] .' next version should be ' . $nextVersion . " or smaller. (prevTimestamp: " . $prevTimestamp . "; step: " . $step, \OCP\Util::DEBUG); + \OCP\Util::writeLog('files_versions', 'Mark to expire '. $version['path'] .' next version should be ' . $nextVersion . " or smaller. (prevTimestamp: " . $prevTimestamp . "; step: " . $step, \OCP\Util::INFO); } else { $nextVersion = $version['version'] - $step; $prevTimestamp = $version['version']; @@ -766,7 +766,7 @@ class Storage { self::deleteVersion($versionsFileview, $path); \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED)); unset($allVersions[$key]); // update array with the versions we keep - \OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::DEBUG); + \OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::INFO); } // Check if enough space is available after versions are rearranged. @@ -782,7 +782,7 @@ class Storage { \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED)); self::deleteVersion($versionsFileview, $version['path'] . '.v' . $version['version']); \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED)); - \OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: ' . $version['path'].'.v'.$version['version'] , \OCP\Util::DEBUG); + \OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: ' . $version['path'].'.v'.$version['version'] , \OCP\Util::INFO); $versionsSize -= $version['size']; $availableSpace += $version['size']; next($allVersions); diff --git a/apps/user_ldap/lib/User/Manager.php b/apps/user_ldap/lib/User/Manager.php index 55d7ac8a81c..767a2351aeb 100644 --- a/apps/user_ldap/lib/User/Manager.php +++ b/apps/user_ldap/lib/User/Manager.php @@ -25,6 +25,7 @@ namespace OCA\User_LDAP\User; +use OC\Cache\CappedMemoryCache; use OCA\User_LDAP\LogWrapper; use OCA\User_LDAP\FilesystemHelper; use OCP\IAvatarManager; @@ -62,14 +63,13 @@ class Manager { protected $avatarManager; /** - * array['byDN'] \OCA\User_LDAP\User\User[] - * ['byUid'] \OCA\User_LDAP\User\User[] - * @var array $users + * @var CappedMemoryCache $usersByDN */ - protected $users = array( - 'byDN' => array(), - 'byUid' => array(), - ); + protected $usersByDN; + /** + * @var CappedMemoryCache $usersByUid + */ + protected $usersByUid; /** * @param IConfig $ocConfig @@ -93,6 +93,8 @@ class Manager { $this->image = $image; $this->db = $db; $this->userManager = $userManager; + $this->usersByDN = new CappedMemoryCache(); + $this->usersByUid = new CappedMemoryCache(); } /** @@ -116,8 +118,8 @@ class Manager { $user = new User($uid, $dn, $this->access, $this->ocConfig, $this->ocFilesystem, clone $this->image, $this->ocLog, $this->avatarManager, $this->userManager); - $this->users['byDN'][$dn] = $user; - $this->users['byUid'][$uid] = $user; + $this->usersByDN[$dn] = $user; + $this->usersByUid[$uid] = $user; return $user; } @@ -219,10 +221,10 @@ class Manager { */ public function get($id) { $this->checkAccess(); - if(isset($this->users['byDN'][$id])) { - return $this->users['byDN'][$id]; - } else if(isset($this->users['byUid'][$id])) { - return $this->users['byUid'][$id]; + if(isset($this->usersByDN[$id])) { + return $this->usersByDN[$id]; + } else if(isset($this->usersByUid[$id])) { + return $this->usersByUid[$id]; } if($this->access->stringResemblesDN($id) ) { diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index 230c82a3045..7929394893b 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -228,6 +228,10 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn return false; } $newDn = $this->access->getUserDnByUuid($uuid); + //check if renamed user is still valid by reapplying the ldap filter + if(!is_array($this->access->readAttribute($newDn, '', $this->access->connection->ldapUserFilter))) { + return false; + } $this->access->getUserMapper()->setDNbyUUID($newDn, $uuid); return true; } catch (\Exception $e) { diff --git a/apps/user_ldap/templates/part.settingcontrols.php b/apps/user_ldap/templates/part.settingcontrols.php index 4dc57eae6d2..3f7a53dd4dc 100644 --- a/apps/user_ldap/templates/part.settingcontrols.php +++ b/apps/user_ldap/templates/part.settingcontrols.php @@ -4,7 +4,7 @@ </button> <a href="<?php p(link_to_docs('admin-ldap')); ?>" target="_blank" rel="noreferrer"> - <img src="<?php print_unescaped(image_path('', 'actions/info.png')); ?>" + <img src="<?php print_unescaped(image_path('', 'actions/info.svg')); ?>" style="height:1.75ex" /> <?php p($l->t('Help'));?> </a> diff --git a/apps/user_ldap/templates/part.wizardcontrols.php b/apps/user_ldap/templates/part.wizardcontrols.php index 4760aa0d8ef..2df1fd8d83f 100644 --- a/apps/user_ldap/templates/part.wizardcontrols.php +++ b/apps/user_ldap/templates/part.wizardcontrols.php @@ -10,7 +10,7 @@ </button> <a href="<?php p(link_to_docs('admin-ldap')); ?>" target="_blank" rel="noreferrer"> - <img src="<?php print_unescaped(image_path('', 'actions/info.png')); ?>" + <img src="<?php print_unescaped(image_path('', 'actions/info.svg')); ?>" style="height:1.75ex" /> <span class="ldap_grey"><?php p($l->t('Help'));?></span> </a> diff --git a/build/integration/features/sharing-v1.feature b/build/integration/features/sharing-v1.feature index 3878e741f60..18dc3447594 100644 --- a/build/integration/features/sharing-v1.feature +++ b/build/integration/features/sharing-v1.feature @@ -26,6 +26,21 @@ Feature: sharing Then the OCS status code should be "100" And the HTTP status code should be "200" + Scenario: Creating a new share with user who already received a share through their group + Given As an "admin" + And user "user0" exists + And user "user1" exists + And group "sharing-group" exists + And user "user1" belongs to group "sharing-group" + And file "welcome.txt" of user "user0" is shared with group "sharing-group" + And As an "user0" + Then sending "POST" to "/apps/files_sharing/api/v1/shares" with + | path | welcome.txt | + | shareWith | user1 | + | shareType | 0 | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + Scenario: Creating a new public share Given user "user0" exists And As an "user0" diff --git a/core/Application.php b/core/Application.php index 8ea2672e54e..a87917b626a 100644 --- a/core/Application.php +++ b/core/Application.php @@ -32,7 +32,6 @@ use OC\AppFramework\Utility\TimeFactory; use OC\Core\Controller\AvatarController; use OC\Core\Controller\LoginController; use OC\Core\Controller\LostController; -use OC\Core\Controller\OccController; use OC\Core\Controller\TokenController; use OC\Core\Controller\TwoFactorChallengeController; use OC\Core\Controller\UserController; @@ -126,18 +125,6 @@ class Application extends App { $c->query('SecureRandom') ); }); - $container->registerService('OccController', function(SimpleContainer $c) { - return new OccController( - $c->query('AppName'), - $c->query('Request'), - $c->query('Config'), - new \OC\Console\Application( - $c->query('Config'), - $c->query('ServerContainer')->getEventDispatcher(), - $c->query('Request') - ) - ); - }); /** * Core class wrappers diff --git a/core/Controller/OccController.php b/core/Controller/OccController.php deleted file mode 100644 index 917d02f37f1..00000000000 --- a/core/Controller/OccController.php +++ /dev/null @@ -1,147 +0,0 @@ -<?php -/** - * @author Victor Dubiniuk <dubiniuk@owncloud.com> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * 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, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OC\Core\Controller; - -use OCP\AppFramework\Controller; -use OCP\AppFramework\Http\JSONResponse; -use OC\Console\Application; -use OCP\IConfig; -use OCP\IRequest; -use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Output\BufferedOutput; - -class OccController extends Controller { - - /** @var array */ - private $allowedCommands = [ - 'app:disable', - 'app:enable', - 'app:getpath', - 'app:list', - 'check', - 'config:list', - 'maintenance:mode', - 'status', - 'upgrade' - ]; - - /** @var IConfig */ - private $config; - /** @var Application */ - private $console; - - /** - * OccController constructor. - * - * @param string $appName - * @param IRequest $request - * @param IConfig $config - * @param Application $console - */ - public function __construct($appName, IRequest $request, - IConfig $config, Application $console) { - parent::__construct($appName, $request); - $this->config = $config; - $this->console = $console; - } - - /** - * @PublicPage - * @NoCSRFRequired - * - * Execute occ command - * Sample request - * POST http://domain.tld/index.php/occ/status', - * { - * 'params': { - * '--no-warnings':'1', - * '--output':'json' - * }, - * 'token': 'someToken' - * } - * - * @param string $command - * @param string $token - * @param array $params - * - * @return JSONResponse - * @throws \Exception - */ - public function execute($command, $token, $params = []) { - try { - $this->validateRequest($command, $token); - - $output = new BufferedOutput(); - $formatter = $output->getFormatter(); - $formatter->setDecorated(false); - $this->console->setAutoExit(false); - $this->console->loadCommands(new ArrayInput([]), $output); - - $inputArray = array_merge(['command' => $command], $params); - $input = new ArrayInput($inputArray); - - $exitCode = $this->console->run($input, $output); - $response = $output->fetch(); - - $json = [ - 'exitCode' => $exitCode, - 'response' => $response - ]; - - } catch (\UnexpectedValueException $e){ - $json = [ - 'exitCode' => 126, - 'response' => 'Not allowed', - 'details' => $e->getMessage() - ]; - } - return new JSONResponse($json); - } - - /** - * Check if command is allowed and has a valid security token - * @param $command - * @param $token - */ - protected function validateRequest($command, $token){ - if (!in_array($this->request->getRemoteAddress(), ['::1', '127.0.0.1', 'localhost'])) { - throw new \UnexpectedValueException('Web executor is not allowed to run from a different host'); - } - - if (!in_array($command, $this->allowedCommands)) { - throw new \UnexpectedValueException(sprintf('Command "%s" is not allowed to run via web request', $command)); - } - - $coreToken = $this->config->getSystemValue('updater.secret', ''); - if ($coreToken === '') { - throw new \UnexpectedValueException( - 'updater.secret is undefined in config/config.php. Either browse the admin settings in your ownCloud and click "Open updater" or define a strong secret using <pre>php -r \'echo password_hash("MyStrongSecretDoUseYourOwn!", PASSWORD_DEFAULT)."\n";\'</pre> and set this in the config.php.' - ); - } - - if (!password_verify($token, $coreToken)) { - throw new \UnexpectedValueException( - 'updater.secret does not match the provided token' - ); - } - } -} diff --git a/core/img/actions/add.png b/core/img/actions/add.png Binary files differdeleted file mode 100644 index 8ae17cfe11b..00000000000 --- a/core/img/actions/add.png +++ /dev/null diff --git a/core/img/actions/caret-dark.png b/core/img/actions/caret-dark.png Binary files differdeleted file mode 100644 index 97c64c6a720..00000000000 --- a/core/img/actions/caret-dark.png +++ /dev/null diff --git a/core/img/actions/caret.png b/core/img/actions/caret.png Binary files differdeleted file mode 100644 index 3a8dd99176d..00000000000 --- a/core/img/actions/caret.png +++ /dev/null diff --git a/core/img/actions/checkbox-checked-disabled.png b/core/img/actions/checkbox-checked-disabled.png Binary files differdeleted file mode 100644 index 55980ba730d..00000000000 --- a/core/img/actions/checkbox-checked-disabled.png +++ /dev/null diff --git a/core/img/actions/checkbox-checked-white.png b/core/img/actions/checkbox-checked-white.png Binary files differdeleted file mode 100644 index ed8e3d3d557..00000000000 --- a/core/img/actions/checkbox-checked-white.png +++ /dev/null diff --git a/core/img/actions/checkbox-checked.png b/core/img/actions/checkbox-checked.png Binary files differdeleted file mode 100644 index 58e9f8ba00b..00000000000 --- a/core/img/actions/checkbox-checked.png +++ /dev/null diff --git a/core/img/actions/checkbox-disabled-white.png b/core/img/actions/checkbox-disabled-white.png Binary files differdeleted file mode 100644 index e1f48439d27..00000000000 --- a/core/img/actions/checkbox-disabled-white.png +++ /dev/null diff --git a/core/img/actions/checkbox-disabled.png b/core/img/actions/checkbox-disabled.png Binary files differdeleted file mode 100644 index a2ead209965..00000000000 --- a/core/img/actions/checkbox-disabled.png +++ /dev/null diff --git a/core/img/actions/checkbox-mixed-white.png b/core/img/actions/checkbox-mixed-white.png Binary files differdeleted file mode 100644 index 0b81f998fc5..00000000000 --- a/core/img/actions/checkbox-mixed-white.png +++ /dev/null diff --git a/core/img/actions/checkbox-mixed.png b/core/img/actions/checkbox-mixed.png Binary files differdeleted file mode 100644 index cc27ec651ea..00000000000 --- a/core/img/actions/checkbox-mixed.png +++ /dev/null diff --git a/core/img/actions/checkbox-white.png b/core/img/actions/checkbox-white.png Binary files differdeleted file mode 100644 index f0f903c77c6..00000000000 --- a/core/img/actions/checkbox-white.png +++ /dev/null diff --git a/core/img/actions/checkbox.png b/core/img/actions/checkbox.png Binary files differdeleted file mode 100644 index 770b7ef8203..00000000000 --- a/core/img/actions/checkbox.png +++ /dev/null diff --git a/core/img/actions/checkmark-color.png b/core/img/actions/checkmark-color.png Binary files differdeleted file mode 100644 index a8ab849cad7..00000000000 --- a/core/img/actions/checkmark-color.png +++ /dev/null diff --git a/core/img/actions/checkmark-white.png b/core/img/actions/checkmark-white.png Binary files differdeleted file mode 100644 index 27f17204b1d..00000000000 --- a/core/img/actions/checkmark-white.png +++ /dev/null diff --git a/core/img/actions/checkmark.png b/core/img/actions/checkmark.png Binary files differdeleted file mode 100644 index c1a8be786cd..00000000000 --- a/core/img/actions/checkmark.png +++ /dev/null diff --git a/core/img/actions/close.png b/core/img/actions/close.png Binary files differdeleted file mode 100644 index 66e3c26cc65..00000000000 --- a/core/img/actions/close.png +++ /dev/null diff --git a/core/img/actions/comment.png b/core/img/actions/comment.png Binary files differdeleted file mode 100644 index 08867cf6361..00000000000 --- a/core/img/actions/comment.png +++ /dev/null diff --git a/core/img/actions/confirm.png b/core/img/actions/confirm.png Binary files differdeleted file mode 100644 index 3021d4c27d6..00000000000 --- a/core/img/actions/confirm.png +++ /dev/null diff --git a/core/img/actions/delete-hover.png b/core/img/actions/delete-hover.png Binary files differdeleted file mode 100644 index ed12640df71..00000000000 --- a/core/img/actions/delete-hover.png +++ /dev/null diff --git a/core/img/actions/delete-white.png b/core/img/actions/delete-white.png Binary files differdeleted file mode 100644 index 07a5de34252..00000000000 --- a/core/img/actions/delete-white.png +++ /dev/null diff --git a/core/img/actions/delete.png b/core/img/actions/delete.png Binary files differdeleted file mode 100644 index 20e894c7f74..00000000000 --- a/core/img/actions/delete.png +++ /dev/null diff --git a/core/img/actions/details.png b/core/img/actions/details.png Binary files differdeleted file mode 100644 index 9145025be26..00000000000 --- a/core/img/actions/details.png +++ /dev/null diff --git a/core/img/actions/download-white.png b/core/img/actions/download-white.png Binary files differdeleted file mode 100644 index 815b551354f..00000000000 --- a/core/img/actions/download-white.png +++ /dev/null diff --git a/core/img/actions/download.png b/core/img/actions/download.png Binary files differdeleted file mode 100644 index 1f8e1a4f7e1..00000000000 --- a/core/img/actions/download.png +++ /dev/null diff --git a/core/img/actions/edit.png b/core/img/actions/edit.png Binary files differdeleted file mode 100644 index 7ca20eba363..00000000000 --- a/core/img/actions/edit.png +++ /dev/null diff --git a/core/img/actions/error-color.png b/core/img/actions/error-color.png Binary files differdeleted file mode 100644 index 7d00282312a..00000000000 --- a/core/img/actions/error-color.png +++ /dev/null diff --git a/core/img/actions/error-white.png b/core/img/actions/error-white.png Binary files differdeleted file mode 100644 index 6e15865401d..00000000000 --- a/core/img/actions/error-white.png +++ /dev/null diff --git a/core/img/actions/error.png b/core/img/actions/error.png Binary files differdeleted file mode 100644 index 61df76b53ea..00000000000 --- a/core/img/actions/error.png +++ /dev/null diff --git a/core/img/actions/external.png b/core/img/actions/external.png Binary files differdeleted file mode 100644 index af03dbf3e05..00000000000 --- a/core/img/actions/external.png +++ /dev/null diff --git a/core/img/actions/history.png b/core/img/actions/history.png Binary files differdeleted file mode 100644 index ec2bbd0587f..00000000000 --- a/core/img/actions/history.png +++ /dev/null diff --git a/core/img/actions/info-white.png b/core/img/actions/info-white.png Binary files differdeleted file mode 100644 index 670d7309c4e..00000000000 --- a/core/img/actions/info-white.png +++ /dev/null diff --git a/core/img/actions/info.png b/core/img/actions/info.png Binary files differdeleted file mode 100644 index b280a019ab4..00000000000 --- a/core/img/actions/info.png +++ /dev/null diff --git a/core/img/actions/logout.png b/core/img/actions/logout.png Binary files differdeleted file mode 100644 index 77391066789..00000000000 --- a/core/img/actions/logout.png +++ /dev/null diff --git a/core/img/actions/mail.png b/core/img/actions/mail.png Binary files differdeleted file mode 100644 index 6d06259cd08..00000000000 --- a/core/img/actions/mail.png +++ /dev/null diff --git a/core/img/actions/menu.png b/core/img/actions/menu.png Binary files differdeleted file mode 100644 index 583ce319175..00000000000 --- a/core/img/actions/menu.png +++ /dev/null diff --git a/core/img/actions/more.png b/core/img/actions/more.png Binary files differdeleted file mode 100644 index 880d5dccce3..00000000000 --- a/core/img/actions/more.png +++ /dev/null diff --git a/core/img/actions/password.png b/core/img/actions/password.png Binary files differdeleted file mode 100644 index 3619fabab9a..00000000000 --- a/core/img/actions/password.png +++ /dev/null diff --git a/core/img/actions/pause-big.png b/core/img/actions/pause-big.png Binary files differdeleted file mode 100644 index 054281c6314..00000000000 --- a/core/img/actions/pause-big.png +++ /dev/null diff --git a/core/img/actions/pause.png b/core/img/actions/pause.png Binary files differdeleted file mode 100644 index d4b865e3401..00000000000 --- a/core/img/actions/pause.png +++ /dev/null diff --git a/core/img/actions/play-add.png b/core/img/actions/play-add.png Binary files differdeleted file mode 100644 index ccf77d2a062..00000000000 --- a/core/img/actions/play-add.png +++ /dev/null diff --git a/core/img/actions/play-big.png b/core/img/actions/play-big.png Binary files differdeleted file mode 100644 index 7d4916cb204..00000000000 --- a/core/img/actions/play-big.png +++ /dev/null diff --git a/core/img/actions/play-next.png b/core/img/actions/play-next.png Binary files differdeleted file mode 100644 index 50cd91d240e..00000000000 --- a/core/img/actions/play-next.png +++ /dev/null diff --git a/core/img/actions/play-previous.png b/core/img/actions/play-previous.png Binary files differdeleted file mode 100644 index c380e96bb58..00000000000 --- a/core/img/actions/play-previous.png +++ /dev/null diff --git a/core/img/actions/play.png b/core/img/actions/play.png Binary files differdeleted file mode 100644 index 7994424c65c..00000000000 --- a/core/img/actions/play.png +++ /dev/null diff --git a/core/img/actions/public.png b/core/img/actions/public.png Binary files differdeleted file mode 100644 index 772838ad205..00000000000 --- a/core/img/actions/public.png +++ /dev/null diff --git a/core/img/actions/radio-checked-disabled.png b/core/img/actions/radio-checked-disabled.png Binary files differdeleted file mode 100644 index 09abc410f61..00000000000 --- a/core/img/actions/radio-checked-disabled.png +++ /dev/null diff --git a/core/img/actions/radio-checked.png b/core/img/actions/radio-checked.png Binary files differdeleted file mode 100644 index f3d06115693..00000000000 --- a/core/img/actions/radio-checked.png +++ /dev/null diff --git a/core/img/actions/radio-disabled.png b/core/img/actions/radio-disabled.png Binary files differdeleted file mode 100644 index ac7f49ed533..00000000000 --- a/core/img/actions/radio-disabled.png +++ /dev/null diff --git a/core/img/actions/radio-white.png b/core/img/actions/radio-white.png Binary files differdeleted file mode 100644 index 04beefdff01..00000000000 --- a/core/img/actions/radio-white.png +++ /dev/null diff --git a/core/img/actions/radio.png b/core/img/actions/radio.png Binary files differdeleted file mode 100644 index 70ac4741b97..00000000000 --- a/core/img/actions/radio.png +++ /dev/null diff --git a/core/img/actions/rename.png b/core/img/actions/rename.png Binary files differdeleted file mode 100644 index 975bd2d7031..00000000000 --- a/core/img/actions/rename.png +++ /dev/null diff --git a/core/img/actions/search-white.png b/core/img/actions/search-white.png Binary files differdeleted file mode 100644 index 9812c44a3d6..00000000000 --- a/core/img/actions/search-white.png +++ /dev/null diff --git a/core/img/actions/search.png b/core/img/actions/search.png Binary files differdeleted file mode 100644 index 5f4767a6f46..00000000000 --- a/core/img/actions/search.png +++ /dev/null diff --git a/core/img/actions/settings.png b/core/img/actions/settings.png Binary files differdeleted file mode 100644 index 3ab939ca37a..00000000000 --- a/core/img/actions/settings.png +++ /dev/null diff --git a/core/img/actions/share.png b/core/img/actions/share.png Binary files differdeleted file mode 100644 index fdacbbabebc..00000000000 --- a/core/img/actions/share.png +++ /dev/null diff --git a/core/img/actions/shared.png b/core/img/actions/shared.png Binary files differdeleted file mode 100644 index fdacbbabebc..00000000000 --- a/core/img/actions/shared.png +++ /dev/null diff --git a/core/img/actions/sound-off.png b/core/img/actions/sound-off.png Binary files differdeleted file mode 100644 index 0457de8e4d1..00000000000 --- a/core/img/actions/sound-off.png +++ /dev/null diff --git a/core/img/actions/sound.png b/core/img/actions/sound.png Binary files differdeleted file mode 100644 index e849b4d248b..00000000000 --- a/core/img/actions/sound.png +++ /dev/null diff --git a/core/img/actions/star.png b/core/img/actions/star.png Binary files differdeleted file mode 100644 index 88e4ad54584..00000000000 --- a/core/img/actions/star.png +++ /dev/null diff --git a/core/img/actions/starred.png b/core/img/actions/starred.png Binary files differdeleted file mode 100644 index 22e68c757e7..00000000000 --- a/core/img/actions/starred.png +++ /dev/null diff --git a/core/img/actions/toggle-filelist.png b/core/img/actions/toggle-filelist.png Binary files differdeleted file mode 100644 index 0926a726d53..00000000000 --- a/core/img/actions/toggle-filelist.png +++ /dev/null diff --git a/core/img/actions/toggle-pictures.png b/core/img/actions/toggle-pictures.png Binary files differdeleted file mode 100644 index 7499d5b7809..00000000000 --- a/core/img/actions/toggle-pictures.png +++ /dev/null diff --git a/core/img/actions/toggle.png b/core/img/actions/toggle.png Binary files differdeleted file mode 100644 index 24a6a4d47de..00000000000 --- a/core/img/actions/toggle.png +++ /dev/null diff --git a/core/img/actions/triangle-e.png b/core/img/actions/triangle-e.png Binary files differdeleted file mode 100644 index 4ce1086f61d..00000000000 --- a/core/img/actions/triangle-e.png +++ /dev/null diff --git a/core/img/actions/triangle-n.png b/core/img/actions/triangle-n.png Binary files differdeleted file mode 100644 index 2042d66532c..00000000000 --- a/core/img/actions/triangle-n.png +++ /dev/null diff --git a/core/img/actions/triangle-s.png b/core/img/actions/triangle-s.png Binary files differdeleted file mode 100644 index 97c64c6a720..00000000000 --- a/core/img/actions/triangle-s.png +++ /dev/null diff --git a/core/img/actions/upload-white.png b/core/img/actions/upload-white.png Binary files differdeleted file mode 100644 index 28693f855d3..00000000000 --- a/core/img/actions/upload-white.png +++ /dev/null diff --git a/core/img/actions/upload.png b/core/img/actions/upload.png Binary files differdeleted file mode 100644 index 8955ed96412..00000000000 --- a/core/img/actions/upload.png +++ /dev/null diff --git a/core/img/actions/user.png b/core/img/actions/user.png Binary files differdeleted file mode 100644 index 5f2fddc0ea3..00000000000 --- a/core/img/actions/user.png +++ /dev/null diff --git a/core/img/actions/view-close.png b/core/img/actions/view-close.png Binary files differdeleted file mode 100644 index eae9acc7a43..00000000000 --- a/core/img/actions/view-close.png +++ /dev/null diff --git a/core/img/actions/view-download.png b/core/img/actions/view-download.png Binary files differdeleted file mode 100644 index 29e1b6fec70..00000000000 --- a/core/img/actions/view-download.png +++ /dev/null diff --git a/core/img/actions/view-next.png b/core/img/actions/view-next.png Binary files differdeleted file mode 100644 index be8cc15cecd..00000000000 --- a/core/img/actions/view-next.png +++ /dev/null diff --git a/core/img/actions/view-pause.png b/core/img/actions/view-pause.png Binary files differdeleted file mode 100644 index 94cd1a5dc6c..00000000000 --- a/core/img/actions/view-pause.png +++ /dev/null diff --git a/core/img/actions/view-play.png b/core/img/actions/view-play.png Binary files differdeleted file mode 100644 index a8398d5758f..00000000000 --- a/core/img/actions/view-play.png +++ /dev/null diff --git a/core/img/actions/view-previous.png b/core/img/actions/view-previous.png Binary files differdeleted file mode 100644 index 86e2a809626..00000000000 --- a/core/img/actions/view-previous.png +++ /dev/null diff --git a/core/img/breadcrumb.png b/core/img/breadcrumb.png Binary files differdeleted file mode 100644 index 5556920aa73..00000000000 --- a/core/img/breadcrumb.png +++ /dev/null diff --git a/core/img/desktopapp.png b/core/img/desktopapp.png Binary files differdeleted file mode 100644 index 272397c949e..00000000000 --- a/core/img/desktopapp.png +++ /dev/null diff --git a/core/img/filetypes/application-pdf.png b/core/img/filetypes/application-pdf.png Binary files differdeleted file mode 100644 index c215094eaa7..00000000000 --- a/core/img/filetypes/application-pdf.png +++ /dev/null diff --git a/core/img/filetypes/application.png b/core/img/filetypes/application.png Binary files differdeleted file mode 100644 index d9db3b9114c..00000000000 --- a/core/img/filetypes/application.png +++ /dev/null diff --git a/core/img/filetypes/audio.png b/core/img/filetypes/audio.png Binary files differdeleted file mode 100644 index 3d52756341a..00000000000 --- a/core/img/filetypes/audio.png +++ /dev/null diff --git a/core/img/filetypes/file.png b/core/img/filetypes/file.png Binary files differdeleted file mode 100644 index 74add13f276..00000000000 --- a/core/img/filetypes/file.png +++ /dev/null diff --git a/core/img/filetypes/folder-drag-accept.png b/core/img/filetypes/folder-drag-accept.png Binary files differdeleted file mode 100644 index 44a3720fef4..00000000000 --- a/core/img/filetypes/folder-drag-accept.png +++ /dev/null diff --git a/core/img/filetypes/folder-external.png b/core/img/filetypes/folder-external.png Binary files differdeleted file mode 100644 index 79dcbeaf731..00000000000 --- a/core/img/filetypes/folder-external.png +++ /dev/null diff --git a/core/img/filetypes/folder-public.png b/core/img/filetypes/folder-public.png Binary files differdeleted file mode 100644 index b9181f640b2..00000000000 --- a/core/img/filetypes/folder-public.png +++ /dev/null diff --git a/core/img/filetypes/folder-shared.png b/core/img/filetypes/folder-shared.png Binary files differdeleted file mode 100644 index 1cc6de7a029..00000000000 --- a/core/img/filetypes/folder-shared.png +++ /dev/null diff --git a/core/img/filetypes/folder-starred.png b/core/img/filetypes/folder-starred.png Binary files differdeleted file mode 100644 index 99d79c14a1d..00000000000 --- a/core/img/filetypes/folder-starred.png +++ /dev/null diff --git a/core/img/filetypes/folder.png b/core/img/filetypes/folder.png Binary files differdeleted file mode 100644 index 2262998cb3c..00000000000 --- a/core/img/filetypes/folder.png +++ /dev/null diff --git a/core/img/filetypes/image.png b/core/img/filetypes/image.png Binary files differdeleted file mode 100644 index 8ff5e6c119f..00000000000 --- a/core/img/filetypes/image.png +++ /dev/null diff --git a/core/img/filetypes/package-x-generic.png b/core/img/filetypes/package-x-generic.png Binary files differdeleted file mode 100644 index 389b44cc2a3..00000000000 --- a/core/img/filetypes/package-x-generic.png +++ /dev/null diff --git a/core/img/filetypes/text-calendar.png b/core/img/filetypes/text-calendar.png Binary files differdeleted file mode 100644 index f21c3a9951d..00000000000 --- a/core/img/filetypes/text-calendar.png +++ /dev/null diff --git a/core/img/filetypes/text-code.png b/core/img/filetypes/text-code.png Binary files differdeleted file mode 100644 index 69744e499e6..00000000000 --- a/core/img/filetypes/text-code.png +++ /dev/null diff --git a/core/img/filetypes/text-vcard.png b/core/img/filetypes/text-vcard.png Binary files differdeleted file mode 100644 index 087eadaabd1..00000000000 --- a/core/img/filetypes/text-vcard.png +++ /dev/null diff --git a/core/img/filetypes/text.png b/core/img/filetypes/text.png Binary files differdeleted file mode 100644 index d6bec70cf43..00000000000 --- a/core/img/filetypes/text.png +++ /dev/null diff --git a/core/img/filetypes/video.png b/core/img/filetypes/video.png Binary files differdeleted file mode 100644 index 7cc1ecdc46a..00000000000 --- a/core/img/filetypes/video.png +++ /dev/null diff --git a/core/img/filetypes/x-office-document.png b/core/img/filetypes/x-office-document.png Binary files differdeleted file mode 100644 index 3bc2f08d1f9..00000000000 --- a/core/img/filetypes/x-office-document.png +++ /dev/null diff --git a/core/img/filetypes/x-office-presentation.png b/core/img/filetypes/x-office-presentation.png Binary files differdeleted file mode 100644 index 644fb852009..00000000000 --- a/core/img/filetypes/x-office-presentation.png +++ /dev/null diff --git a/core/img/filetypes/x-office-spreadsheet.png b/core/img/filetypes/x-office-spreadsheet.png Binary files differdeleted file mode 100644 index 8f79c32fe01..00000000000 --- a/core/img/filetypes/x-office-spreadsheet.png +++ /dev/null diff --git a/core/img/logo-icon.png b/core/img/logo-icon.png Binary files differdeleted file mode 100644 index 4ffb2bb953a..00000000000 --- a/core/img/logo-icon.png +++ /dev/null diff --git a/core/img/places/calendar-dark.png b/core/img/places/calendar-dark.png Binary files differdeleted file mode 100644 index 9dc21d8a7b8..00000000000 --- a/core/img/places/calendar-dark.png +++ /dev/null diff --git a/core/img/places/contacts-dark.png b/core/img/places/contacts-dark.png Binary files differdeleted file mode 100644 index fe03bbfe1a4..00000000000 --- a/core/img/places/contacts-dark.png +++ /dev/null diff --git a/core/img/places/files.png b/core/img/places/files.png Binary files differdeleted file mode 100644 index e317fc3c722..00000000000 --- a/core/img/places/files.png +++ /dev/null diff --git a/core/img/places/home.png b/core/img/places/home.png Binary files differdeleted file mode 100644 index 2e0313d59a7..00000000000 --- a/core/img/places/home.png +++ /dev/null diff --git a/core/img/places/link.png b/core/img/places/link.png Binary files differdeleted file mode 100644 index 8ba9f6530fb..00000000000 --- a/core/img/places/link.png +++ /dev/null diff --git a/core/img/places/music.png b/core/img/places/music.png Binary files differdeleted file mode 100644 index 0670544fedc..00000000000 --- a/core/img/places/music.png +++ /dev/null diff --git a/core/img/places/picture.png b/core/img/places/picture.png Binary files differdeleted file mode 100644 index 171af526e9d..00000000000 --- a/core/img/places/picture.png +++ /dev/null diff --git a/core/js/jquery.ocdialog.js b/core/js/jquery.ocdialog.js index ea034f0aff7..15b58f9e086 100644 --- a/core/js/jquery.ocdialog.js +++ b/core/js/jquery.ocdialog.js @@ -145,7 +145,7 @@ break; case 'closeButton': if(value) { - var $closeButton = $('<a class="oc-dialog-close svg"></a>'); + var $closeButton = $('<a class="oc-dialog-close"></a>'); this.$dialog.prepend($closeButton); $closeButton.on('click', function() { self.close(); diff --git a/core/js/js.js b/core/js/js.js index 7f98668dcb2..07ed396bec9 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -327,8 +327,8 @@ var OC={ * @return {string} */ imagePath:function(app,file){ - if(file.indexOf('.')==-1){//if no extension is given, use png or svg depending on browser support - file+=(OC.Util.hasSVGSupport())?'.svg':'.png'; + if(file.indexOf('.')==-1){//if no extension is given, use svg + file+='.svg'; } return OC.filePath(app,'img',file); }, @@ -592,7 +592,7 @@ var OC={ var arrowclass = settings.hasClass('topright') ? 'up' : 'left'; var jqxhr = $.get(OC.filePath(props.appid, '', props.scriptName), function(data) { popup.html(data).ready(function() { - popup.prepend('<span class="arrow '+arrowclass+'"></span><h2>'+t('core', 'Settings')+'</h2><a class="close svg"></a>').show(); + popup.prepend('<span class="arrow '+arrowclass+'"></span><h2>'+t('core', 'Settings')+'</h2><a class="close"></a>').show(); popup.find('.close').bind('click', function() { popup.remove(); }); @@ -613,9 +613,6 @@ var OC={ throw e; }); } - if(!OC.Util.hasSVGSupport()) { - OC.Util.replaceSVG(); - } }).show(); }, 'html'); } @@ -1358,49 +1355,6 @@ if(typeof localStorage !=='undefined' && localStorage !== null){ } /** - * check if the browser support svg images - * @return {boolean} - */ -function SVGSupport() { - return SVGSupport.checkMimeType.correct && !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect; -} -SVGSupport.checkMimeType=function(){ - $.ajax({ - url: OC.imagePath('core','breadcrumb.svg'), - success:function(data,text,xhr){ - var headerParts=xhr.getAllResponseHeaders().split("\n"); - var headers={}; - $.each(headerParts,function(i,text){ - if(text){ - var parts=text.split(':',2); - if(parts.length===2){ - var value=parts[1].trim(); - if(value[0]==='"'){ - value=value.substr(1,value.length-2); - } - headers[parts[0].toLowerCase()]=value; - } - } - }); - if(headers["content-type"]!=='image/svg+xml'){ - OC.Util.replaceSVG(); - SVGSupport.checkMimeType.correct=false; - } - } - }); -}; -SVGSupport.checkMimeType.correct=true; - -/** - * Replace all svg images with png for browser compatibility - * @param $el - * @deprecated use OC.Util.replaceSVG instead - */ -function replaceSVG($el){ - return OC.Util.replaceSVG($el); -} - -/** * prototypical inheritance functions * @todo Write documentation * usage: @@ -1517,12 +1471,6 @@ function initCore() { initSessionHeartBeat(); } - if(!OC.Util.hasSVGSupport()){ //replace all svg images with png images for browser that don't support svg - OC.Util.replaceSVG(); - }else{ - SVGSupport.checkMimeType(); - } - OC.registerMenu($('#expand'), $('#expanddiv')); // toggle for menus @@ -1791,24 +1739,21 @@ OC.Util = { }, /** * Returns whether the browser supports SVG + * @deprecated SVG is always supported (since 9.0) * @return {boolean} true if the browser supports SVG, false otherwise */ - // TODO: replace with original function - hasSVGSupport: SVGSupport, + hasSVGSupport: function(){ + return true + }, /** * If SVG is not supported, replaces the given icon's extension * from ".svg" to ".png". * If SVG is supported, return the image path as is. * @param {string} file image path with svg extension + * @deprecated SVG is always supported (since 9.0) * @return {string} fixed image path with png extension if SVG is not supported */ replaceSVGIcon: function(file) { - if (file && !OC.Util.hasSVGSupport()) { - var i = file.lastIndexOf('.svg'); - if (i >= 0) { - file = file.substr(0, i) + '.png' + file.substr(i+4); - } - } return file; }, /** @@ -1816,39 +1761,9 @@ OC.Util = { * with PNG images. * * @param $el root element from which to search, defaults to $('body') + * @deprecated SVG is always supported (since 9.0) */ - replaceSVG: function($el) { - if (!$el) { - $el = $('body'); - } - $el.find('img.svg').each(function(index,element){ - element=$(element); - var src=element.attr('src'); - element.attr('src',src.substr(0, src.length-3) + 'png'); - }); - $el.find('.svg').each(function(index,element){ - element = $(element); - var background = element.css('background-image'); - if (background){ - var i = background.lastIndexOf('.svg'); - if (i >= 0){ - background = background.substr(0,i) + '.png' + background.substr(i + 4); - element.css('background-image', background); - } - } - element.find('*').each(function(index, element) { - element = $(element); - var background = element.css('background-image'); - if (background) { - var i = background.lastIndexOf('.svg'); - if(i >= 0){ - background = background.substr(0,i) + '.png' + background.substr(i + 4); - element.css('background-image', background); - } - } - }); - }); - }, + replaceSVG: function($el) {}, /** * Fix image scaling for IE8, since background-size is not supported. diff --git a/core/js/mimetype.js b/core/js/mimetype.js index 3cc33ce2830..0d30da26c26 100644 --- a/core/js/mimetype.js +++ b/core/js/mimetype.js @@ -29,7 +29,7 @@ OC.MimeType = { * Cache that maps mimeTypes to icon urls */ _mimeTypeIcons: {}, - + /** * Return the file icon we want to use for the given mimeType. * The file needs to be present in the supplied file list @@ -60,7 +60,7 @@ OC.MimeType = { return null; }, - + /** * Return the url to icon of the given mimeType * @@ -91,19 +91,14 @@ OC.MimeType = { path += icon; } } - + // If we do not yet have an icon fall back to the default if (gotIcon === null) { path = OC.webroot + '/core/img/filetypes/'; path += OC.MimeType._getFile(mimeType, OC.MimeTypeList.files); } - // Use svg if we can - if(OC.Util.hasSVGSupport()){ - path += '.svg'; - } else { - path += '.png'; - } + path += '.svg'; // Cache the result OC.MimeType._mimeTypeIcons[mimeType] = path; @@ -111,5 +106,3 @@ OC.MimeType = { } }; - - diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 83fde154615..85dee978987 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -38,7 +38,7 @@ '<span class="shareOption">' + '<input id="canEdit-{{cid}}-{{shareWith}}" type="checkbox" name="edit" class="permissions checkbox" {{#if hasEditPermission}}checked="checked"{{/if}} />' + '<label for="canEdit-{{cid}}-{{shareWith}}">{{canEditLabel}}</label>' + - '<a href="#" class="showCruds"><img class="svg" alt="{{crudsLabel}}" src="{{triangleSImage}}"/></a>' + + '<a href="#" class="showCruds"><img alt="{{crudsLabel}}" src="{{triangleSImage}}"/></a>' + '</span>' + '{{/if}}' + '<div class="cruds hidden">' + diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index a4bfde1777b..c17da94bab3 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -30,7 +30,7 @@ '<div class="loading hidden" style="height: 50px"></div>'; var TEMPLATE_REMOTE_SHARE_INFO = - '<a target="_blank" class="icon-info svg shareWithRemoteInfo hasTooltip" href="{{docLink}}" ' + + '<a target="_blank" class="icon-info shareWithRemoteInfo hasTooltip" href="{{docLink}}" ' + 'title="{{tooltip}}"></a>'; /** diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 56ed3f0039b..8ea0bf28b38 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -187,7 +187,7 @@ }).fail(function(xhr) { var msg = t('core', 'Error'); var result = xhr.responseJSON; - if (result.ocs && result.ocs.meta) { + if (result && result.ocs && result.ocs.meta) { msg = result.ocs.meta.message; } diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index 3d19a38c416..1ffe7b38a40 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -231,22 +231,12 @@ describe('Core base tests', function() { }); describe('Images', function() { it('Generates image path with given extension', function() { - var svgSupportStub = sinon.stub(OC.Util, 'hasSVGSupport', function() { return true; }); expect(OC.imagePath('core', 'somefile.jpg')).toEqual(OC.webroot + '/core/img/somefile.jpg'); expect(OC.imagePath(TESTAPP, 'somefile.jpg')).toEqual(TESTAPP_ROOT + '/img/somefile.jpg'); - svgSupportStub.restore(); }); - it('Generates image path with svg extension when svg support exists', function() { - var svgSupportStub = sinon.stub(OC.Util, 'hasSVGSupport', function() { return true; }); + it('Generates image path with svg extension', function() { expect(OC.imagePath('core', 'somefile')).toEqual(OC.webroot + '/core/img/somefile.svg'); expect(OC.imagePath(TESTAPP, 'somefile')).toEqual(TESTAPP_ROOT + '/img/somefile.svg'); - svgSupportStub.restore(); - }); - it('Generates image path with png ext when svg support is not available', function() { - var svgSupportStub = sinon.stub(OC.Util, 'hasSVGSupport', function() { return false; }); - expect(OC.imagePath('core', 'somefile')).toEqual(OC.webroot + '/core/img/somefile.png'); - expect(OC.imagePath(TESTAPP, 'somefile')).toEqual(TESTAPP_ROOT + '/img/somefile.png'); - svgSupportStub.restore(); }); }); }); @@ -504,32 +494,6 @@ describe('Core base tests', function() { expect($navigation.is(':visible')).toEqual(false); }); }); - describe('SVG extension replacement', function() { - var svgSupportStub; - - beforeEach(function() { - svgSupportStub = sinon.stub(OC.Util, 'hasSVGSupport'); - }); - afterEach(function() { - svgSupportStub.restore(); - }); - it('does not replace svg extension with png when SVG is supported', function() { - svgSupportStub.returns(true); - expect( - OC.Util.replaceSVGIcon('/path/to/myicon.svg?someargs=1') - ).toEqual( - '/path/to/myicon.svg?someargs=1' - ); - }); - it('replaces svg extension with png when SVG not supported', function() { - svgSupportStub.returns(false); - expect( - OC.Util.replaceSVGIcon('/path/to/myicon.svg?someargs=1') - ).toEqual( - '/path/to/myicon.png?someargs=1' - ); - }); - }); describe('Util', function() { describe('humanFileSize', function() { it('renders file sizes with the correct unit', function() { @@ -1017,4 +981,3 @@ describe('Core base tests', function() { }); }); }); - diff --git a/core/routes.php b/core/routes.php index c473408e2e9..402277d8f3e 100644 --- a/core/routes.php +++ b/core/routes.php @@ -48,7 +48,6 @@ $application->registerRoutes($this, [ ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], ['name' => 'token#generateToken', 'url' => '/token/generate', 'verb' => 'POST'], - ['name' => 'occ#execute', 'url' => '/occ/{command}', 'verb' => 'POST'], ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], diff --git a/core/templates/installation.php b/core/templates/installation.php index a4dbb078344..f7556988634 100644 --- a/core/templates/installation.php +++ b/core/templates/installation.php @@ -51,13 +51,13 @@ script('core', [ autocomplete="off" autocapitalize="off" autocorrect="off" required> <label for="adminpass" class="infield"><?php p($l->t( 'Password' )); ?></label> <input type="checkbox" id="show" name="show"> - <label for="show" class="svg"></label> + <label for="show"></label> </p> </fieldset> <?php if(!$_['directoryIsSet'] OR !$_['dbIsSet'] OR count($_['errors']) > 0): ?> <fieldset id="advancedHeader"> - <legend><a id="showAdvanced"><?php p($l->t( 'Storage & database' )); ?> <img class="svg" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" /></a></legend> + <legend><a id="showAdvanced"><?php p($l->t( 'Storage & database' )); ?> <img src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" /></a></legend> </fieldset> <?php endif; ?> @@ -161,7 +161,7 @@ script('core', [ <div class="buttons"><input type="submit" class="primary" value="<?php p($l->t( 'Finish setup' )); ?>" data-finishing="<?php p($l->t( 'Finishing …' )); ?>"></div> <p class="info"> - <span class="icon-info-white svg"></span> + <span class="icon-info-white"></span> <?php p($l->t('Need help?'));?> <a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-install')); ?>"><?php p($l->t('See the documentation'));?> ↗</a> </p> diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 985e95294ad..58506353158 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -31,7 +31,7 @@ <?php if ($_['bodyid'] === 'body-login' ): ?> <header role="banner"> <div id="header"> - <div class="logo svg"> + <div class="logo"> <h1 class="hidden-visually"> <?php p($theme->getName()); ?> </h1> diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index d42a392f40f..4a6937c6ea0 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -39,7 +39,7 @@ <header role="banner"><div id="header"> <a href="<?php print_unescaped(link_to('', 'index.php')); ?>" id="owncloud" tabindex="1"> - <div class="logo-icon svg"> + <div class="logo-icon"> <h1 class="hidden-visually"> <?php p($theme->getName()); ?> </h1> @@ -56,11 +56,11 @@ } ?> </h1> - <div class="icon-caret svg"></div> + <div class="icon-caret"></div> </a> <div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div> - <div id="settings" class="svg"> + <div id="settings"> <div id="expand" tabindex="6" role="link" class="menutoggle"> <?php if ($_['enableAvatars']): ?> <div class="avatardiv<?php if ($_['userAvatarSet']) { print_unescaped(' avatardiv-shown'); } else { print_unescaped('" style="display: none'); } ?>"> @@ -73,7 +73,7 @@ </div> <?php endif; ?> <span id="expandDisplayName"><?php p(trim($_['user_displayname']) != '' ? $_['user_displayname'] : $_['user_uid']) ?></span> - <img class="svg" alt="" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>"> + <img alt="" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>"> </div> <div id="expanddiv"> <ul> @@ -81,14 +81,14 @@ <li> <a href="<?php print_unescaped($entry['href']); ?>" <?php if( $entry["active"] ): ?> class="active"<?php endif; ?>> - <img class="svg" alt="" src="<?php print_unescaped($entry['icon']); ?>"> + <img alt="" src="<?php print_unescaped($entry['icon']); ?>"> <?php p($entry['name']) ?> </a> </li> <?php endforeach; ?> <li> <a id="logout" <?php print_unescaped(OC_User::getLogoutAttribute()); ?>> - <img class="svg" alt="" src="<?php print_unescaped(image_path('', 'actions/logout.svg')); ?>"> + <img alt="" src="<?php print_unescaped(image_path('', 'actions/logout.svg')); ?>"> <?php p($l->t('Log out'));?> </a> </li> @@ -100,20 +100,20 @@ <label for="searchbox" class="hidden-visually"> <?php p($l->t('Search'));?> </label> - <input id="searchbox" class="svg" type="search" name="query" + <input id="searchbox" type="search" name="query" value="" required autocomplete="off" tabindex="5"> </form> </div></header> <nav role="navigation"><div id="navigation"> - <div id="apps" class="svg"> + <div id="apps"> <ul> <?php foreach($_['navigation'] as $entry): ?> <li data-id="<?php p($entry['id']); ?>"> <a href="<?php print_unescaped($entry['href']); ?>" tabindex="3" <?php if( $entry['active'] ): ?> class="active"<?php endif; ?>> - <img class="app-icon svg" alt="" src="<?php print_unescaped($entry['icon']); ?>"> + <img class="app-icon" alt="" src="<?php print_unescaped($entry['icon']); ?>"> <div class="icon-loading-dark" style="display:none;"></div> <span> <?php p($entry['name']); ?> @@ -128,7 +128,7 @@ <li id="apps-management"> <a href="<?php print_unescaped(\OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')); ?>" tabindex="4" <?php if( $_['appsmanagement_active'] ): ?> class="active"<?php endif; ?>> - <img class="app-icon svg" alt="" src="<?php print_unescaped(image_path('settings', 'apps.svg')); ?>"> + <img class="app-icon" alt="" src="<?php print_unescaped(image_path('settings', 'apps.svg')); ?>"> <div class="icon-loading-dark" style="display:none;"></div> <span> <?php p($l->t('Apps')); ?> diff --git a/core/templates/login.php b/core/templates/login.php index 5b0fd97cfd8..95c5a423c3d 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -53,7 +53,7 @@ script('core', [ <?php p($_['user_autofocus'] ? '' : 'autofocus'); ?> autocomplete="on" autocapitalize="off" autocorrect="off" required> <label for="password" class="infield"><?php p($l->t('Password')); ?></label> - <input type="submit" id="submit" class="login primary icon-confirm svg" title="<?php p($l->t('Log in')); ?>" value="" disabled="disabled"/> + <input type="submit" id="submit" class="login primary icon-confirm" title="<?php p($l->t('Log in')); ?>" value="" disabled="disabled"/> </p> <?php if (!empty($_['invalidpassword']) && !empty($_['canResetPassword'])) { ?> diff --git a/core/templates/update.admin.php b/core/templates/update.admin.php index 24b2beec6da..87f93967d91 100644 --- a/core/templates/update.admin.php +++ b/core/templates/update.admin.php @@ -47,7 +47,7 @@ <p id="update-progress-message-error" class="warning hidden"></p> <ul id="update-progress-message-warnings" class="warning hidden"></ul> <p id="update-progress-message"></p> - <a class="update-show-detailed"><?php p($l->t( 'Detailed logs' )); ?> <img class="svg" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" /></a> + <a class="update-show-detailed"><?php p($l->t( 'Detailed logs' )); ?> <img src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" /></a> <div id="update-progress-detailed" class="hidden warning"></div> </div> </div> diff --git a/lib/base.php b/lib/base.php index dde8e38218a..70fac6d707b 100644 --- a/lib/base.php +++ b/lib/base.php @@ -49,8 +49,6 @@ * */ -use OCP\IRequest; - require_once 'public/Constants.php'; /** @@ -273,20 +271,9 @@ class OC { } } - /** - * Limit maintenance mode access - * @param IRequest $request - */ - public static function checkMaintenanceMode(IRequest $request) { - // Check if requested URL matches 'index.php/occ' - $isOccControllerRequested = preg_match('|/index\.php$|', $request->getScriptName()) === 1 - && strpos($request->getPathInfo(), '/occ/') === 0; + public static function checkMaintenanceMode() { // Allow ajax update script to execute without being stopped - if ( - \OC::$server->getSystemConfig()->getValue('maintenance', false) - && OC::$SUBURI != '/core/ajax/update.php' - && !$isOccControllerRequested - ) { + if (\OC::$server->getSystemConfig()->getValue('maintenance', false) && OC::$SUBURI != '/core/ajax/update.php') { // send http status 503 header('HTTP/1.1 503 Service Temporarily Unavailable'); header('Status: 503 Service Temporarily Unavailable'); @@ -835,7 +822,7 @@ class OC { $request = \OC::$server->getRequest(); $requestPath = $request->getRawPathInfo(); if (substr($requestPath, -3) !== '.js') { // we need these files during the upgrade - self::checkMaintenanceMode($request); + self::checkMaintenanceMode(); self::checkUpgrade(); } diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php index 8a9191a4c53..ec91064278e 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -138,10 +138,9 @@ class Application { * @throws \Exception */ public function run(InputInterface $input = null, OutputInterface $output = null) { - $args = isset($this->request->server['argv']) ? $this->request->server['argv'] : []; $this->dispatcher->dispatch(ConsoleEvent::EVENT_RUN, new ConsoleEvent( ConsoleEvent::EVENT_RUN, - $args + $this->request->server['argv'] )); return $this->application->run($input, $output); } diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index 6191eae2754..2d68c92b14e 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -283,21 +283,21 @@ class Detection implements IMimeTypeDetector { // Is it a dir? if ($mimetype === 'dir') { - $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder.png'); + $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder.svg'); return $this->mimetypeIcons[$mimetype]; } if ($mimetype === 'dir-shared') { - $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder-shared.png'); + $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder-shared.svg'); return $this->mimetypeIcons[$mimetype]; } if ($mimetype === 'dir-external') { - $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder-external.png'); + $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder-external.svg'); return $this->mimetypeIcons[$mimetype]; } // Icon exists? try { - $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $icon . '.png'); + $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $icon . '.svg'); return $this->mimetypeIcons[$mimetype]; } catch (\RuntimeException $e) { // Specified image not found @@ -306,13 +306,13 @@ class Detection implements IMimeTypeDetector { // Try only the first part of the filetype $mimePart = substr($icon, 0, strpos($icon, '-')); try { - $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.png'); + $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg'); return $this->mimetypeIcons[$mimetype]; } catch (\RuntimeException $e) { // Image for the first part of the mimetype not found } - $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/file.png'); + $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/file.svg'); return $this->mimetypeIcons[$mimetype]; } } diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 31549c93cb2..7d9771e6394 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1980,7 +1980,7 @@ class View { $mount = $this->getMountForLock($absolutePath, $lockMountPoint); if ($mount) { $storage = $mount->getStorage(); - if ($storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($storage && $storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { $storage->releaseLock( $mount->getInternalPath($absolutePath), $type, diff --git a/lib/private/Preview/MP3.php b/lib/private/Preview/MP3.php index 8b1a0500538..f96b422f57a 100644 --- a/lib/private/Preview/MP3.php +++ b/lib/private/Preview/MP3.php @@ -68,7 +68,7 @@ class MP3 extends Provider { * @return bool|\OCP\IImage false if the default image is missing or invalid */ private function getNoCoverThumbnail() { - $icon = \OC::$SERVERROOT . '/core/img/filetypes/audio.png'; + $icon = \OC::$SERVERROOT . '/core/img/filetypes/audio.svg'; if(!file_exists($icon)) { return false; diff --git a/lib/private/SystemTag/SystemTagManager.php b/lib/private/SystemTag/SystemTagManager.php index 3e32582025f..7055fafbf24 100644 --- a/lib/private/SystemTag/SystemTagManager.php +++ b/lib/private/SystemTag/SystemTagManager.php @@ -140,7 +140,10 @@ class SystemTagManager implements ISystemTagManager { if (!empty($nameSearchPattern)) { $query->andWhere( - $query->expr()->like('name', $query->createNamedParameter('%' . $this->connection->escapeLikeParameter($nameSearchPattern) . '%')) + $query->expr()->like( + 'name', + $query->createNamedParameter('%' . $this->connection->escapeLikeParameter($nameSearchPattern). '%') + ) ); } diff --git a/public.php b/public.php index b7125502ee8..964ed03c1aa 100644 --- a/public.php +++ b/public.php @@ -35,9 +35,9 @@ try { exit; } - $request = \OC::$server->getRequest(); - OC::checkMaintenanceMode($request); + OC::checkMaintenanceMode(); OC::checkSingleUserMode(true); + $request = \OC::$server->getRequest(); $pathInfo = $request->getPathInfo(); if (!$pathInfo && $request->getParam('service', '') === '') { diff --git a/settings/Controller/AuthSettingsController.php b/settings/Controller/AuthSettingsController.php index db2db6e5bfc..e7fc2d916bc 100644 --- a/settings/Controller/AuthSettingsController.php +++ b/settings/Controller/AuthSettingsController.php @@ -81,7 +81,28 @@ class AuthSettingsController extends Controller { if (is_null($user)) { return []; } - return $this->tokenProvider->getTokenByUser($user); + $tokens = $this->tokenProvider->getTokenByUser($user); + + try { + $sessionId = $this->session->getId(); + } catch (SessionNotAvailableException $ex) { + return $this->getServiceNotAvailableResponse(); + } + try { + $sessionToken = $this->tokenProvider->getToken($sessionId); + } catch (InvalidTokenException $ex) { + return $this->getServiceNotAvailableResponse(); + } + + return array_map(function(IToken $token) use ($sessionToken) { + $data = $token->jsonSerialize(); + if ($sessionToken->getId() === $token->getId()) { + $data['canDelete'] = false; + } else { + $data['canDelete'] = true; + } + return $data; + }, $tokens); } /** @@ -94,9 +115,7 @@ class AuthSettingsController extends Controller { try { $sessionId = $this->session->getId(); } catch (SessionNotAvailableException $ex) { - $resp = new JSONResponse(); - $resp->setStatus(Http::STATUS_SERVICE_UNAVAILABLE); - return $resp; + return $this->getServiceNotAvailableResponse(); } try { @@ -108,9 +127,7 @@ class AuthSettingsController extends Controller { $password = null; } } catch (InvalidTokenException $ex) { - $resp = new JSONResponse(); - $resp->setStatus(Http::STATUS_SERVICE_UNAVAILABLE); - return $resp; + return $this->getServiceNotAvailableResponse(); } $token = $this->generateRandomDeviceToken(); @@ -123,6 +140,12 @@ class AuthSettingsController extends Controller { ]; } + private function getServiceNotAvailableResponse() { + $resp = new JSONResponse(); + $resp->setStatus(Http::STATUS_SERVICE_UNAVAILABLE); + return $resp; + } + /** * Return a 20 digit device password * diff --git a/settings/js/authtoken_view.js b/settings/js/authtoken_view.js index 01fc1b2ea34..472b841c230 100644 --- a/settings/js/authtoken_view.js +++ b/settings/js/authtoken_view.js @@ -29,7 +29,11 @@ '<tr data-id="{{id}}">' + '<td class="has-tooltip" title="{{name}}"><span class="token-name">{{name}}</span></td>' + '<td><span class="last-activity has-tooltip" title="{{lastActivityTime}}">{{lastActivity}}</span></td>' + + '{{#if canDelete}}' + '<td><a class="icon-delete has-tooltip" title="' + t('core', 'Disconnect') + '"></a></td>' + + '{{else}}' + + '<td></td>' + + '{{/if}}' + '<tr>'; var SubView = OC.Backbone.View.extend({ diff --git a/settings/js/users/users.js b/settings/js/users/users.js index e0fccbd9539..e0fdea64773 100644 --- a/settings/js/users/users.js +++ b/settings/js/users/users.js @@ -117,7 +117,7 @@ var UserList = { * remove action */ if ($tr.find('td.remove img').length === 0 && OC.currentUser !== user.name) { - var deleteImage = $('<img class="svg action">').attr({ + var deleteImage = $('<img class="action">').attr({ src: OC.imagePath('core', 'actions/delete') }); var deleteLink = $('<a class="action delete">') @@ -138,10 +138,13 @@ var UserList = { .find('option').attr('selected', null) .first().attr('selected', 'selected'); } else { - if ($quotaSelect.find('option').filterAttr('value', user.quota).length > 0) { - $quotaSelect.find('option').filterAttr('value', user.quota).attr('selected', 'selected'); + var $options = $quotaSelect.find('option'); + var $foundOption = $options.filterAttr('value', user.quota); + if ($foundOption.length > 0) { + $foundOption.attr('selected', 'selected'); } else { - $quotaSelect.append('<option value="' + escapeHTML(user.quota) + '" selected="selected">' + escapeHTML(user.quota) + '</option>'); + // append before "Other" entry + $options.last().before('<option value="' + escapeHTML(user.quota) + '" selected="selected">' + escapeHTML(user.quota) + '</option>'); } } @@ -576,6 +579,15 @@ var UserList = { var $select = $(ev.target); var uid = UserList.getUID($select); var quota = $select.val(); + if (quota === 'other') { + return; + } + if (isNaN(parseInt(quota, 10)) || parseInt(quota, 10) < 0) { + // the select component has added the bogus value, delete it again + $select.find('option[selected]').remove(); + OC.Notification.showTemporary(t('core', 'Invalid quota value "{val}"', {val: quota})); + return; + } UserList._updateQuota(uid, quota, function(returnedQuota){ if (quota !== returnedQuota) { $select.find(':selected').text(returnedQuota); diff --git a/settings/templates/admin.php b/settings/templates/admin.php index c0a7424cf67..f41c0d3c101 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -202,7 +202,7 @@ if ($_['cronErrors']) { <div class="section" id="shareAPI"> <h2><?php p($l->t('Sharing'));?></h2> - <a target="_blank" el="noreferrer" class="icon-info svg" + <a target="_blank" el="noreferrer" class="icon-info" title="<?php p($l->t('Open documentation'));?>" href="<?php p(link_to_docs('admin-sharing')); ?>"></a> <p id="enable"> @@ -314,7 +314,7 @@ if ($_['cronErrors']) { endif; ?> </p> <?php endif; ?> - <a target="_blank" rel="noreferrer" class="icon-info svg" + <a target="_blank" rel="noreferrer" class="icon-info" title="<?php p($l->t('Open documentation'));?>" href="<?php p(link_to_docs('admin-background-jobs')); ?>"></a> @@ -346,7 +346,7 @@ if ($_['cronErrors']) { <div class="section" id='encryptionAPI'> <h2><?php p($l->t('Server-side encryption')); ?></h2> - <a target="_blank" rel="noreferrer" class="icon-info svg" + <a target="_blank" rel="noreferrer" class="icon-info" title="<?php p($l->t('Open documentation'));?>" href="<?php p(link_to_docs('admin-encryption')); ?>"></a> @@ -412,7 +412,7 @@ if ($_['cronErrors']) { <div class="section" id="mail_general_settings"> <form id="mail_general_settings_form" class="mail_settings"> <h2><?php p($l->t('Email server'));?></h2> - <a target="_blank" rel="noreferrer" class="icon-info svg" + <a target="_blank" rel="noreferrer" class="icon-info" title="<?php p($l->t('Open documentation'));?>" href="<?php p(link_to_docs('admin-email')); ?>"></a> diff --git a/settings/templates/certificates.php b/settings/templates/certificates.php index c1ccdcaef95..16f8dda31ad 100644 --- a/settings/templates/certificates.php +++ b/settings/templates/certificates.php @@ -26,7 +26,7 @@ <?php else: ?>style="visibility:hidden;" <?php endif; ?>><img alt="<?php p($l->t('Delete')); ?>" title="<?php p($l->t('Delete')); ?>" - class="svg action" + class="action" src="<?php print_unescaped(image_path('core', 'actions/delete.svg')); ?>"/> </td> </tr> diff --git a/settings/templates/personal.php b/settings/templates/personal.php index bcc803938ba..2f656d39fbb 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -39,9 +39,9 @@ <div class="avatardiv"></div> <div class="warning hidden"></div> <?php if ($_['avatarChangeSupported']): ?> - <label for="uploadavatar" class="inlineblock button icon-upload svg" id="uploadavatarbutton" title="<?php p($l->t('Upload new')); ?>"></label> - <div class="inlineblock button icon-folder svg" id="selectavatar" title="<?php p($l->t('Select from Files')); ?>"></div> - <div class="hidden button icon-delete svg" id="removeavatar" title="<?php p($l->t('Remove image')); ?>"></div> + <label for="uploadavatar" class="inlineblock button icon-upload" id="uploadavatarbutton" title="<?php p($l->t('Upload new')); ?>"></label> + <div class="inlineblock button icon-folder" id="selectavatar" title="<?php p($l->t('Select from Files')); ?>"></div> + <div class="hidden button icon-delete" id="removeavatar" title="<?php p($l->t('Remove image')); ?>"></div> <input type="file" name="files[]" id="uploadavatar" class="hiddenuploadfield"> <p><em><?php p($l->t('png or jpg, max. 20 MB')); ?></em></p> <?php else: ?> @@ -129,7 +129,7 @@ if($_['passwordChangeSupported']) { placeholder="<?php echo $l->t('New password');?>" data-typetoggle="#personal-show" autocomplete="off" autocapitalize="off" autocorrect="off" /> - <input type="checkbox" id="personal-show" name="show" /><label for="personal-show" class="svg"></label> + <input type="checkbox" id="personal-show" name="show" /><label for="personal-show"></label> <input id="passwordbutton" type="submit" value="<?php echo $l->t('Change password');?>" /> <br/> </form> diff --git a/settings/templates/users/part.grouplist.php b/settings/templates/users/part.grouplist.php index cd6ac4a1e89..64c602c364c 100644 --- a/settings/templates/users/part.grouplist.php +++ b/settings/templates/users/part.grouplist.php @@ -8,7 +8,7 @@ <li id="newgroup-form" style="display: none"> <form> <input type="text" id="newgroupname" placeholder="<?php p($l->t('Group')); ?>..." /> - <input type="submit" class="button icon-add svg" value="" /> + <input type="submit" class="button icon-add" value="" /> </form> </li> <!-- Everyone --> @@ -45,7 +45,7 @@ <span class="usercount"><?php if($group['usercount'] > 0) { p($group['usercount']); } ?></span> <?php if($_['isAdmin']): ?> <a href="#" class="action delete" original-title="<?php p($l->t('Delete'))?>"> - <img src="<?php print_unescaped(image_path('core', 'actions/delete.svg')) ?>" class="svg" /> + <img src="<?php print_unescaped(image_path('core', 'actions/delete.svg')) ?>" /> </a> <?php endif; ?> </span> diff --git a/settings/templates/users/part.userlist.php b/settings/templates/users/part.userlist.php index 697d0f3f142..c7b2ad58c15 100644 --- a/settings/templates/users/part.userlist.php +++ b/settings/templates/users/part.userlist.php @@ -26,15 +26,15 @@ <td class="avatar"><div class="avatardiv"></div></td> <?php endif; ?> <th class="name" scope="row"></th> - <td class="displayName"><span></span> <img class="svg action" + <td class="displayName"><span></span> <img class="action" src="<?php p(image_path('core', 'actions/rename.svg'))?>" alt="<?php p($l->t("change full name"))?>" title="<?php p($l->t("change full name"))?>"/> </td> - <td class="password"><span>●●●●●●●</span> <img class="svg action" + <td class="password"><span>●●●●●●●</span> <img class="action" src="<?php print_unescaped(image_path('core', 'actions/rename.svg'))?>" alt="<?php p($l->t("set new password"))?>" title="<?php p($l->t("set new password"))?>"/> </td> - <td class="mailAddress"><span></span><div class="loading-small hidden"></div> <img class="svg action" + <td class="mailAddress"><span></span><div class="loading-small hidden"></div> <img class="action" src="<?php p(image_path('core', 'actions/rename.svg'))?>" alt="<?php p($l->t('change email address'))?>" title="<?php p($l->t('change email address'))?>"/> </td> diff --git a/tests/Core/Controller/OccControllerTest.php b/tests/Core/Controller/OccControllerTest.php deleted file mode 100644 index 682d9170096..00000000000 --- a/tests/Core/Controller/OccControllerTest.php +++ /dev/null @@ -1,143 +0,0 @@ -<?php -/** - * @author Victor Dubiniuk <dubiniuk@owncloud.com> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * 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, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace Tests\Core\Controller; - -use OC\Console\Application; -use OC\Core\Controller\OccController; -use OCP\IConfig; -use Symfony\Component\Console\Output\Output; -use Test\TestCase; - -/** - * Class OccControllerTest - * - * @package OC\Core\Controller - */ -class OccControllerTest extends TestCase { - - const TEMP_SECRET = 'test'; - - /** @var \OC\AppFramework\Http\Request | \PHPUnit_Framework_MockObject_MockObject */ - private $request; - /** @var \OC\Core\Controller\OccController | \PHPUnit_Framework_MockObject_MockObject */ - private $controller; - /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */ - private $config; - /** @var Application | \PHPUnit_Framework_MockObject_MockObject */ - private $console; - - public function testFromInvalidLocation(){ - $this->getControllerMock('example.org'); - - $response = $this->controller->execute('status', ''); - $responseData = $response->getData(); - - $this->assertArrayHasKey('exitCode', $responseData); - $this->assertEquals(126, $responseData['exitCode']); - - $this->assertArrayHasKey('details', $responseData); - $this->assertEquals('Web executor is not allowed to run from a different host', $responseData['details']); - } - - public function testNotWhiteListedCommand(){ - $this->getControllerMock('localhost'); - - $response = $this->controller->execute('missing_command', ''); - $responseData = $response->getData(); - - $this->assertArrayHasKey('exitCode', $responseData); - $this->assertEquals(126, $responseData['exitCode']); - - $this->assertArrayHasKey('details', $responseData); - $this->assertEquals('Command "missing_command" is not allowed to run via web request', $responseData['details']); - } - - public function testWrongToken(){ - $this->getControllerMock('localhost'); - - $response = $this->controller->execute('status', self::TEMP_SECRET . '-'); - $responseData = $response->getData(); - - $this->assertArrayHasKey('exitCode', $responseData); - $this->assertEquals(126, $responseData['exitCode']); - - $this->assertArrayHasKey('details', $responseData); - $this->assertEquals('updater.secret does not match the provided token', $responseData['details']); - } - - public function testSuccess(){ - $this->getControllerMock('localhost'); - $this->console->expects($this->once())->method('run') - ->willReturnCallback( - function ($input, $output) { - /** @var Output $output */ - $output->writeln('{"installed":true,"version":"9.1.0.8","versionstring":"9.1.0 beta 2","edition":""}'); - return 0; - } - ); - - $response = $this->controller->execute('status', self::TEMP_SECRET, ['--output'=>'json']); - $responseData = $response->getData(); - - $this->assertArrayHasKey('exitCode', $responseData); - $this->assertEquals(0, $responseData['exitCode']); - - $this->assertArrayHasKey('response', $responseData); - $decoded = json_decode($responseData['response'], true); - - $this->assertArrayHasKey('installed', $decoded); - $this->assertEquals(true, $decoded['installed']); - } - - private function getControllerMock($host){ - $this->request = $this->getMockBuilder('OC\AppFramework\Http\Request') - ->setConstructorArgs([ - ['server' => []], - \OC::$server->getSecureRandom(), - \OC::$server->getConfig() - ]) - ->setMethods(['getRemoteAddress']) - ->getMock(); - - $this->request->expects($this->any())->method('getRemoteAddress') - ->will($this->returnValue($host)); - - $this->config = $this->getMockBuilder('\OCP\IConfig') - ->disableOriginalConstructor() - ->getMock(); - $this->config->expects($this->any())->method('getSystemValue') - ->with('updater.secret') - ->willReturn(password_hash(self::TEMP_SECRET, PASSWORD_DEFAULT)); - - $this->console = $this->getMockBuilder('\OC\Console\Application') - ->disableOriginalConstructor() - ->getMock(); - - $this->controller = new OccController( - 'core', - $this->request, - $this->config, - $this->console - ); - } - -} diff --git a/tests/Settings/Controller/AuthSettingsControllerTest.php b/tests/Settings/Controller/AuthSettingsControllerTest.php index ee67b221022..1705cb5ddf1 100644 --- a/tests/Settings/Controller/AuthSettingsControllerTest.php +++ b/tests/Settings/Controller/AuthSettingsControllerTest.php @@ -24,6 +24,7 @@ namespace Test\Settings\Controller; use OC\AppFramework\Http; use OC\Authentication\Exceptions\InvalidTokenException; +use OC\Authentication\Token\DefaultToken; use OC\Authentication\Token\IToken; use OC\Settings\Controller\AuthSettingsController; use OCP\AppFramework\Http\JSONResponse; @@ -56,10 +57,17 @@ class AuthSettingsControllerTest extends TestCase { } public function testIndex() { - $result = [ - 'token1', - 'token2', + $token1 = new DefaultToken(); + $token1->setId(100); + $token2 = new DefaultToken(); + $token2->setId(200); + $tokens = [ + $token1, + $token2, ]; + $sessionToken = new DefaultToken(); + $sessionToken->setId(100); + $this->userManager->expects($this->once()) ->method('get') ->with($this->uid) @@ -67,9 +75,31 @@ class AuthSettingsControllerTest extends TestCase { $this->tokenProvider->expects($this->once()) ->method('getTokenByUser') ->with($this->user) - ->will($this->returnValue($result)); + ->will($this->returnValue($tokens)); + $this->session->expects($this->once()) + ->method('getId') + ->will($this->returnValue('session123')); + $this->tokenProvider->expects($this->once()) + ->method('getToken') + ->with('session123') + ->will($this->returnValue($sessionToken)); - $this->assertEquals($result, $this->controller->index()); + $this->assertEquals([ + [ + 'id' => 100, + 'name' => null, + 'lastActivity' => null, + 'type' => null, + 'canDelete' => false, + ], + [ + 'id' => 200, + 'name' => null, + 'lastActivity' => null, + 'type' => null, + 'canDelete' => true, + ] + ], $this->controller->index()); } public function testCreate() { @@ -107,6 +137,7 @@ class AuthSettingsControllerTest extends TestCase { $expected = [ 'token' => $newToken, 'deviceToken' => $deviceToken, + 'loginName' => 'User13', ]; $this->assertEquals($expected, $this->controller->create($name)); } diff --git a/tests/Settings/Controller/LogSettingsControllerTest.php b/tests/Settings/Controller/LogSettingsControllerTest.php index e3cfa072d08..f296df9903c 100644 --- a/tests/Settings/Controller/LogSettingsControllerTest.php +++ b/tests/Settings/Controller/LogSettingsControllerTest.php @@ -71,9 +71,9 @@ class LogSettingsControllerTest extends \Test\TestCase { public function testDownload() { $response = $this->logSettingsController->download(); - $expected = new StreamResponse(\OC\Log\Owncloud::getLogFilePath()); - $expected->addHeader('Content-Type', 'application/octet-stream'); - $expected->addHeader('Content-Disposition', 'attachment; filename="nextcloud.log"'); - $this->assertEquals($expected, $response); + $this->assertInstanceOf('\OCP\AppFramework\Http\StreamResponse', $response); + $headers = $response->getHeaders(); + $this->assertEquals('application/octet-stream', $headers['Content-Type']); + $this->assertEquals('attachment; filename="nextcloud.log"', $headers['Content-Disposition']); } } diff --git a/tests/objectstore/start-swift-ceph.sh b/tests/objectstore/start-swift-ceph.sh index 089aab6a648..bbf483c2897 100755 --- a/tests/objectstore/start-swift-ceph.sh +++ b/tests/objectstore/start-swift-ceph.sh @@ -30,6 +30,7 @@ thisFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # create readiness notification socket notify_sock=$(readlink -f "$thisFolder"/dockerContainerCeph.$EXECUTOR_NUMBER.swift.sock) +rm -f "$notify_sock" # in case an unfinished test left one behind mkfifo "$notify_sock" port=5034 @@ -67,7 +68,13 @@ if [[ $ready != 'READY=1' ]]; then docker logs $container exit 1 fi -sleep 1 +if ! "$thisFolder"/wait-for-connection ${host} 80 600; then + echo "[ERROR] Waited 600 seconds, no response" >&2 + docker logs $container + exit 1 +fi +echo "Waiting another 15 seconds" +sleep 15 cat > $thisFolder/swift.config.php <<DELIM <?php @@ -101,5 +108,7 @@ if [ -n "$DEBUG" ]; then cat $thisFolder/swift.config.php echo "### contents of $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift" cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift + echo "### docker logs" + docker logs $container echo "############## DEBUG info end ###########" fi diff --git a/tests/objectstore/wait-for-connection b/tests/objectstore/wait-for-connection new file mode 100755 index 00000000000..2c480fb733e --- /dev/null +++ b/tests/objectstore/wait-for-connection @@ -0,0 +1,45 @@ +#!/usr/bin/php +<?php + +$timeout = 60; + +switch ($argc) { +case 4: + $timeout = (float)$argv[3]; +case 3: + $host = $argv[1]; + $port = (int)$argv[2]; + break; +default: + fwrite(STDERR, 'Usage: '.$argv[0].' host port [timeout]'."\n"); + exit(2); +} + +if ($timeout < 0) { + fwrite(STDERR, 'Timeout must be greater than zero'."\n"); + exit(2); +} +if ($port < 1) { + fwrite(STDERR, 'Port must be an integer greater than zero'."\n"); + exit(2); +} + +$socketTimeout = (float)ini_get('default_socket_timeout'); +if ($socketTimeout > $timeout) { + $socketTimeout = $timeout; +} + +$stopTime = time() + $timeout; +do { + $sock = @fsockopen($host, $port, $errno, $errstr, $socketTimeout); + if ($sock !== false) { + fclose($sock); + fwrite(STDOUT, "\n"); + exit(0); + } + sleep(1); + fwrite(STDOUT, '.'); +} while (time() < $stopTime); + +fwrite(STDOUT, "\n"); +exit(1); |