Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync master #333

Merged
merged 51 commits into from
Jul 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6c1ea7a
Fix "Other" value handling in quota dropdown in users page
Jun 23, 2016
819b7c4
Prevent negative or non-number values in quota input
Jun 24, 2016
ee67484
better detect errors in fed sharing response
icewind1991 Jun 24, 2016
8d32e1d
Handle exceptions thrown while trying to notify remote server of a fe…
icewind1991 Jun 24, 2016
646c90c
Log reason why we removed the fed share
icewind1991 Jun 27, 2016
dc6c234
prevent users from deleting their own session token
ChristophWurst Jun 27, 2016
cb3b678
hide hidden parameters from list backend/auth parameters
icewind1991 Jun 30, 2016
17036c4
show configuration options for authentication backends while listing …
icewind1991 Jun 30, 2016
6802fd2
Filelist change dir auto-prepend slash
Jul 1, 2016
aaf4c30
Add all properties while creating a subscription (#25318)
tcitworld Jul 1, 2016
e42ce62
Merge pull request #25276 from owncloud/delete-own-session-token
Jul 1, 2016
027715f
Merge pull request #25262 from owncloud/fed-sharing-error
Jul 1, 2016
1ad97f8
remove javascript png fallback for svg
Henni Jun 23, 2016
6cc6538
remove png actions, fileicons, etc
Henni Jun 23, 2016
9e7e3de
remove png references in core
Henni Jun 23, 2016
0a8f7bd
remove svg classes
Henni Jun 23, 2016
5cc0147
adjusts tests to removal of svg fallback
Henni Jun 29, 2016
b0bad03
[tx-robot] updated from transifex
Jul 2, 2016
6a89a63
[tx-robot] updated from transifex
Jul 3, 2016
59fc3ff
[tx-robot] updated from transifex
Jul 4, 2016
6b4b337
Cap LDAP user cache (#25323)
butonic Jul 4, 2016
aa42d60
check if renamed user is still valid by reapplying the ldap filter (#…
felixboehm Jul 4, 2016
8147eef
Change nickvergessen mailmap entry (#25349)
nickvergessen Jul 4, 2016
a573b68
Merge pull request #25314 from owncloud/files_external-backends-config
Jul 4, 2016
a35747b
Merge pull request #25253 from owncloud/users-fixotherquotadropdown
Jul 4, 2016
8b8d2b6
Merge pull request #25240 from owncloud/remove-svg
MorrisJobke Jul 4, 2016
89e581a
Bypass upgrade page when occ controller is requested
VicDeo Jul 5, 2016
e7cc8ba
[tx-robot] updated from transifex
Jul 5, 2016
3bde47c
fix swift primary object store test (#25281)
DeepDiver1975 Jul 5, 2016
647e168
Add integration test for sharing with group, then user in group
Jul 5, 2016
1d10d58
Merge pull request #25344 from owncloud/fix-ldap-check-user
Jul 5, 2016
e668cf1
Merge pull request #25356 from owncloud/checkupgrade-bypass
Jul 5, 2016
94d9111
[tx-robot] updated from transifex
Jul 6, 2016
9c9062c
Upgrading the log level From Debug to INFO to be consistent with file…
cdamken Jul 6, 2016
147c672
Ignore invalid paths in the JS file list (#25368)
Jul 6, 2016
e0b5a64
Merge pull request #25325 from owncloud/filelist-prependslash
Jul 6, 2016
db45607
Merge pull request #25361 from owncloud/sharing-inttestforusershareaf…
Jul 6, 2016
e4d1851
Use named parameter instead of direct value for system tags search pa…
Jul 6, 2016
a3b6735
Set content type when downloading log file to force download in some …
Jul 6, 2016
3731b2a
[tx-robot] updated from transifex
Jul 7, 2016
49f344b
Revert "[tx-robot] updated from transifex"
MorrisJobke Jul 7, 2016
d36ede4
Merge branch 'master' into sync-master
MorrisJobke Jul 7, 2016
00eaa3e
Revert "Bypass upgrade page when occ controller is requested"
MorrisJobke Jul 7, 2016
4e06726
Revert "occ web executor (#24957)"
MorrisJobke Jul 7, 2016
13ae263
Change png icons to svg
jvillafanez Jul 7, 2016
54716b7
Add expiration date to share by link view
MorrisJobke Sep 30, 2015
1320fc4
add "Never" if expiration date is not set
MorrisJobke Oct 2, 2015
5f9e709
Not set expiration date is represented as 0
MorrisJobke Mar 16, 2016
7652c33
Update header during update callback
MorrisJobke Apr 1, 2016
190d771
add unit tests
MorrisJobke Jul 4, 2016
b6209f4
Simplify test code and don't show anything if no date is set
MorrisJobke Jul 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
25 changes: 15 additions & 10 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -1079,22 +1079,27 @@ function createSubscription($principalUri, $uri, array $properties) {
'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');
Expand Down
8 changes: 7 additions & 1 deletion apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,20 @@ public function testSyncSupport() {

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();
Expand All @@ -350,6 +355,7 @@ public function testSubscriptions() {
$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);
Expand Down
59 changes: 36 additions & 23 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,28 +217,32 @@ protected function createFederatedShare(IShare $share) {
$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;
Expand Down Expand Up @@ -526,13 +530,22 @@ protected function revokeShare($share, $isOwner) {
* @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();
}

Expand Down
60 changes: 56 additions & 4 deletions apps/federatedfilesharing/tests/FederatedShareProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ public function testCreateCouldNotFindServer() {
'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]);
Expand All @@ -244,6 +240,62 @@ public function testCreateCouldNotFindServer() {
$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();

Expand Down
21 changes: 19 additions & 2 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},
Expand Down Expand Up @@ -1397,14 +1397,28 @@
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
* @param changeUrl true to also update the URL, false otherwise (default)
* @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);

Expand All @@ -1415,6 +1429,9 @@
this.setPageTitle();
}

if (targetDir.length > 0 && targetDir[0] !== '/') {
targetDir = '/' + targetDir;
}
this._currentDirectory = targetDir;

// legacy stuff
Expand Down
37 changes: 31 additions & 6 deletions apps/files/tests/js/filelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
Expand Down
21 changes: 18 additions & 3 deletions apps/files_external/lib/Command/Backends.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,30 @@ private function serializeAuthBackend(\JsonSerializable $backend) {
$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);
}
}
Loading