Skip to content

Commit 980d900

Browse files
authored
Merge pull request #334 from nextcloud/sync-stable9
Sync stable9
2 parents e5645a9 + f593a09 commit 980d900

14 files changed

Lines changed: 169 additions & 55 deletions

File tree

apps/dav/appinfo/application.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use OCA\Dav\Migration\CalendarAdapter;
3333
use OCA\Dav\Migration\MigrateAddressbooks;
3434
use OCA\Dav\Migration\MigrateCalendars;
35+
use OCA\Dav\Migration\NothingToDoException;
3536
use \OCP\AppFramework\App;
3637
use OCP\AppFramework\IAppContainer;
3738
use OCP\Contacts\IManager;
@@ -190,6 +191,8 @@ public function migrateAddressbooks() {
190191
/** @var IUser $user */
191192
$migration->migrateForUser($user->getUID());
192193
});
194+
} catch (NothingToDoException $ex) {
195+
// nothing to do, yay!
193196
} catch (\Exception $ex) {
194197
$this->getContainer()->getServer()->getLogger()->logException($ex);
195198
}
@@ -206,6 +209,8 @@ public function migrateCalendars() {
206209
/** @var IUser $user */
207210
$migration->migrateForUser($user->getUID());
208211
});
212+
} catch (NothingToDoException $ex) {
213+
// nothing to do, yay!
209214
} catch (\Exception $ex) {
210215
$this->getContainer()->getServer()->getLogger()->logException($ex);
211216
}

apps/dav/lib/migration/addressbookadapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function foreachBook($user, \Closure $callBack) {
6969

7070
public function setup() {
7171
if (!$this->dbConnection->tableExists($this->sourceBookTable)) {
72-
throw new \DomainException('Contacts tables are missing. Nothing to do.');
72+
throw new NothingToDoException('Contacts tables are missing');
7373
}
7474
}
7575

apps/dav/lib/migration/calendaradapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function foreachCalendar($user, \Closure $callBack) {
6565

6666
public function setup() {
6767
if (!$this->dbConnection->tableExists($this->sourceCalendarTable)) {
68-
throw new \DomainException('Calendar tables are missing. Nothing to do.');
68+
throw new NothingToDoException('Calendar tables are missing');
6969
}
7070
}
7171

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* @author Robin McCorkell <[email protected]>
4+
*
5+
* @copyright Copyright (c) 2016, ownCloud, Inc.
6+
* @license AGPL-3.0
7+
*
8+
* This code is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License, version 3,
10+
* as published by the Free Software Foundation.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Affero General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Affero General Public License, version 3,
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>
19+
*
20+
*/
21+
22+
namespace OCA\Dav\Migration;
23+
24+
/**
25+
* Exception if no migration needs to be done
26+
*/
27+
class NothingToDoException extends \DomainException {}

apps/files/js/filelist.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,13 +1327,27 @@
13271327
return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/');
13281328
},
13291329

1330+
_isValidPath: function(path) {
1331+
var sections = path.split('/');
1332+
for (var i = 0; i < sections.length; i++) {
1333+
if (sections[i] === '..') {
1334+
return false;
1335+
}
1336+
}
1337+
return true;
1338+
},
1339+
13301340
/**
13311341
* Sets the current directory name and updates the breadcrumb.
13321342
* @param targetDir directory to display
13331343
* @param changeUrl true to also update the URL, false otherwise (default)
13341344
*/
13351345
_setCurrentDir: function(targetDir, changeUrl) {
1336-
targetDir = targetDir.replace(/\\/g, '/').replace(/\/\.\.\//g, '/');
1346+
targetDir = targetDir.replace(/\\/g, '/');
1347+
if (!this._isValidPath(targetDir)) {
1348+
targetDir = '/';
1349+
changeUrl = true;
1350+
}
13371351
var previousDir = this.getCurrentDirectory(),
13381352
baseDir = OC.basename(targetDir);
13391353

apps/files/tests/js/filelistSpec.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,13 +1323,32 @@ describe('OCA.Files.FileList tests', function() {
13231323
fileList.changeDirectory('/another\\subdir');
13241324
expect(fileList.getCurrentDirectory()).toEqual('/another/subdir');
13251325
});
1326-
it('converts backslashes to slashes and removes traversals when calling changeDirectory()', function() {
1327-
fileList.changeDirectory('/another\\subdir/../foo\\../bar\\..\\file/..\\folder/../');
1328-
expect(fileList.getCurrentDirectory()).toEqual('/another/subdir/foo/bar/file/folder/');
1326+
it('switches to root dir when current directory is invalid', function() {
1327+
_.each([
1328+
'..',
1329+
'/..',
1330+
'../',
1331+
'/../',
1332+
'/../abc',
1333+
'/abc/..',
1334+
'/abc/../',
1335+
'/../abc/',
1336+
'/another\\subdir/../foo\\../bar\\..\\file/..\\folder/../'
1337+
], function(path) {
1338+
fileList.changeDirectory(path);
1339+
expect(fileList.getCurrentDirectory()).toEqual('/');
1340+
});
13291341
});
1330-
it('does not convert folders with a ".." in the name', function() {
1331-
fileList.changeDirectory('/abc../def');
1332-
expect(fileList.getCurrentDirectory()).toEqual('/abc../def');
1342+
it('allows paths with dotdot at the beginning or end', function() {
1343+
_.each([
1344+
'/..abc',
1345+
'/def..',
1346+
'/...',
1347+
'/abc../def'
1348+
], function(path) {
1349+
fileList.changeDirectory(path);
1350+
expect(fileList.getCurrentDirectory()).toEqual(path);
1351+
});
13331352
});
13341353
it('switches to root dir when current directory does not exist', function() {
13351354
fileList.changeDirectory('/unexist');

apps/files_versions/lib/storage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ protected static function getAutoExpireList($time, $versions) {
644644
//distance between two version too small, mark to delete
645645
$toDelete[$key] = $version['path'] . '.v' . $version['version'];
646646
$size += $version['size'];
647-
\OCP\Util::writeLog('files_versions', 'Mark to expire '. $version['path'] .' next version should be ' . $nextVersion . " or smaller. (prevTimestamp: " . $prevTimestamp . "; step: " . $step, \OCP\Util::DEBUG);
647+
\OCP\Util::writeLog('files_versions', 'Mark to expire '. $version['path'] .' next version should be ' . $nextVersion . " or smaller. (prevTimestamp: " . $prevTimestamp . "; step: " . $step, \OCP\Util::INFO);
648648
} else {
649649
$nextVersion = $version['version'] - $step;
650650
$prevTimestamp = $version['version'];
@@ -765,7 +765,7 @@ public static function expire($filename) {
765765
self::deleteVersion($versionsFileview, $path);
766766
\OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
767767
unset($allVersions[$key]); // update array with the versions we keep
768-
\OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::DEBUG);
768+
\OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::INFO);
769769
}
770770

771771
// Check if enough space is available after versions are rearranged.
@@ -781,7 +781,7 @@ public static function expire($filename) {
781781
\OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
782782
self::deleteVersion($versionsFileview, $version['path'] . '.v' . $version['version']);
783783
\OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
784-
\OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: ' . $version['path'].'.v'.$version['version'] , \OCP\Util::DEBUG);
784+
\OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: ' . $version['path'].'.v'.$version['version'] , \OCP\Util::INFO);
785785
$versionsSize -= $version['size'];
786786
$availableSpace += $version['size'];
787787
next($allVersions);

apps/user_ldap/user_ldap.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ public function userExistsOnLDAP($user) {
228228
return false;
229229
}
230230
$newDn = $this->access->getUserDnByUuid($uuid);
231+
//check if renamed user is still valid by reapplying the ldap filter
232+
if(!is_array($this->access->readAttribute($newDn, '', $this->access->connection->ldapUserFilter))) {
233+
return false;
234+
}
235+
231236
$this->access->getUserMapper()->setDNbyUUID($newDn, $uuid);
232237
return true;
233238
} catch (\Exception $e) {

build/integration/features/sharing-v1.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ Feature: sharing
2626
Then the OCS status code should be "100"
2727
And the HTTP status code should be "200"
2828

29+
Scenario: Creating a new share with user who already received a share through their group
30+
Given As an "admin"
31+
And user "user0" exists
32+
And user "user1" exists
33+
And group "sharing-group" exists
34+
And user "user1" belongs to group "sharing-group"
35+
And file "welcome.txt" of user "user0" is shared with group "sharing-group"
36+
And As an "user0"
37+
Then sending "POST" to "/apps/files_sharing/api/v1/shares" with
38+
| path | welcome.txt |
39+
| shareWith | user1 |
40+
| shareType | 0 |
41+
Then the OCS status code should be "100"
42+
And the HTTP status code should be "200"
43+
2944
Scenario: Creating a new public share
3045
Given user "user0" exists
3146
And As an "user0"

core/command/encryption/decryptall.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* @author Björn Schießle <[email protected]>
3+
* @author Björn Schießle <[email protected]>
44
* @author Joas Schilling <[email protected]>
55
*
66
* @copyright Copyright (c) 2016, ownCloud, Inc.
@@ -111,7 +111,8 @@ protected function configure() {
111111
$this->addArgument(
112112
'user',
113113
InputArgument::OPTIONAL,
114-
'user for which you want to decrypt all files (optional)'
114+
'user for which you want to decrypt all files (optional)',
115+
''
115116
);
116117
}
117118

@@ -127,8 +128,15 @@ protected function execute(InputInterface $input, OutputInterface $output) {
127128
return;
128129
}
129130

131+
$uid = $input->getArgument('user');
132+
if ($uid === '') {
133+
$message = 'your Nextcloud';
134+
} else {
135+
$message = "$uid's account";
136+
}
137+
130138
$output->writeln("\n");
131-
$output->writeln('You are about to start to decrypt all files stored in your Nextcloud.');
139+
$output->writeln("You are about to start to decrypt all files stored in $message.");
132140
$output->writeln('It will depend on the encryption module and your setup if this is possible.');
133141
$output->writeln('Depending on the number and size of your files this can take some time');
134142
$output->writeln('Please make sure that no user access his files during this process!');
@@ -140,6 +148,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
140148
$result = $this->decryptAll->decryptAll($input, $output, $user);
141149
if ($result === false) {
142150
$output->writeln(' aborted.');
151+
$output->writeln('Server side encryption remains enabled');
143152
$this->config->setAppValue('core', 'encryption_enabled', 'yes');
144153
}
145154
$this->resetSingleUserAndTrashbin();

0 commit comments

Comments
 (0)