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

[stable10] Allow deletion of group with special characters #30111

Merged
merged 1 commit into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion settings/Controller/GroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function create($id) {
* @return DataResponse
*/
public function destroy($id) {
$group = $this->groupManager->get($id);
$group = $this->groupManager->get(urldecode($id));
if ($group) {
if ($group->delete()) {
return new DataResponse(
Expand Down
2 changes: 1 addition & 1 deletion settings/js/users/deleteHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ DeleteHandler.prototype.showNotification = function() {
}
$('#notification').data(this.notificationDataID, true);
var msg = this.notificationMessage.replace(
this.notificationPlaceholder, escapeHTML(this.oidToDelete));
this.notificationPlaceholder, escapeHTML(decodeURIComponent(this.oidToDelete)));
this.notifier.showHtml(msg);
}
};
Expand Down
2 changes: 1 addition & 1 deletion settings/js/users/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ GroupList = {
},

getElementGID: function (element) {
return ($(element).closest('li').attr('data-gid') || '').toString();
return encodeURIComponent(($(element).closest('li').attr('data-gid') || '')).toString();
},
getEveryoneCount: function () {
$.ajax({
Expand Down
21 changes: 17 additions & 4 deletions tests/Settings/Controller/GroupsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,26 @@ public function testCreateUnsuccessful() {
$this->assertEquals($expectedResponse, $response);
}

public function testDestroySuccessful() {
public function destroyData() {
return [
['ExistingGroup'],
['a/b'],
['a*2&&bc//f!!'],
['!c@\\$%^&*()|2']
];
}

/**
* Test destroy works with special characters also
* @dataProvider destroyData
*/
public function testDestroySuccessful($groupName) {
$group = $this->getMockBuilder('\OC\Group\Group')
->disableOriginalConstructor()->getMock();
$this->container['GroupManager']
->expects($this->once())
->method('get')
->with('ExistingGroup')
->with($groupName)
->will($this->returnValue($group));
$group
->expects($this->once())
Expand All @@ -312,11 +325,11 @@ public function testDestroySuccessful() {
$expectedResponse = new DataResponse(
[
'status' => 'success',
'data' => ['groupname' => 'ExistingGroup']
'data' => ['groupname' => $groupName]
],
Http::STATUS_NO_CONTENT
);
$response = $this->groupsController->destroy('ExistingGroup');
$response = $this->groupsController->destroy($groupName);
$this->assertEquals($expectedResponse, $response);
}

Expand Down