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

Use select2 for the groups excluded from sharing in admin page #10968

Merged
merged 8 commits into from
Sep 19, 2014

Conversation

PVince81
Copy link
Contributor

@PVince81 PVince81 commented Sep 9, 2014

First commit moves select2 to core
Second commit uses select2 in the admin page for the groups selection:

groupselect

Please review @schiesbn @owncloud/designers @butonic @MTRichards @LukasReschke

Fixes #10936
Fixes second part of #9014

If you guys like it I'll do the same for the apps page, next.

@PVince81 PVince81 added this to the 2014-sprint-03-current milestone Sep 9, 2014
@PVince81
Copy link
Contributor Author

PVince81 commented Sep 9, 2014

CC @ser72 this should fix the admin page slowness, check it out!

@ser72
Copy link

ser72 commented Sep 9, 2014

@butonic @PVince81 @MTRichards

Tested with an LDAP consisting of 10000 users.
Admin page came up very quickly with External Storage app enabled 👍

Admin page hangs with Sharepoint integration, and I assume it will with Windows Network Drive as well, however I am having issues enabling that app. 👎

@ghost
Copy link

ghost commented Sep 9, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/7166/

@ghost
Copy link

ghost commented Sep 9, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/7168/

@PVince81
Copy link
Contributor Author

PVince81 commented Sep 9, 2014

@ser72 you have issue enabling the app because the app page is slow ?
I'll soon push the second part of the fix: putting the same select box on the apps page.

@PVince81
Copy link
Contributor Author

PVince81 commented Sep 9, 2014

Added select2 on the apps page as well.

Fixes #9012

Will rebase now.

Vincent Petry added 2 commits September 9, 2014 18:04
The ajax call is now using ajax/appconfig.php instead
Moved setupGroupsSelect() from admin.js to a common settings.js
as OC.Settings.setupGoupsSelect().

Now using select2 as well on the apps page.
@PVince81 PVince81 force-pushed the admin-groupsselect2 branch from bde9641 to 0d28ba0 Compare September 9, 2014 16:05
@PVince81
Copy link
Contributor Author

PVince81 commented Sep 9, 2014

Rebased.

@ser72 please try again: the apps page should be more responsive now.

Please review @icewind1991 @schiesbn @butonic @owncloud/designers

Two things to look at now:

  1. "Exclude group groups" in admin page, groups select box
  2. Enable an app for specific groups: groups select box

Have fun 😄

@ghost
Copy link

ghost commented Sep 9, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/7170/

callback(selection);
},
formatResult: function (element) {
return element.displayname;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💣 💣 💣

👎 XSS detected - you need to escape this. (escapeHTML(element.displayname))

💣 💣 💣

@LukasReschke
Copy link
Member

  • When adding a new group to the exclude from sharing dropdown two requests are send to appconfig.php - the first one results in an error 500
  • The exclude from share checkbox does not work with groups that contain a comma in the name
  • Enable app for specific group dropdown does not work with groups that contain a comma in the name

@PVince81
Copy link
Contributor Author

@LukasReschke select2 already escapes this internally, that's why I removed the escapeHTML things. From the docs:

String escapeMarkup(String markup)

Function used to post-process markup returned from formatter functions. By default this function escapes html entities to prevent javascript injection.

http://ivaynberg.github.io/select2/

But I'll double check with a debugger.

I didn't know group names could have a comma !? I'm pretty sure that will break other parts of OC as well. Is there a safer separator ? (select2 can work with a configurable separator)

@LukasReschke
Copy link
Member

@LukasReschke select2 already escapes this internally, that's why I removed the escapeHTML things. From the docs:

Well, it doesn't change anything about the fact that this is exploitable. Do not trust the docs ;-)

@LukasReschke
Copy link
Member

I didn't know group names could have a comma !? I'm pretty sure that will break other parts of OC as well. Is there a safer separator ? (select2 can work with a configurable separator)

What about JSON serialize the data?

@PVince81
Copy link
Contributor Author

The dumb thing is that if I manually escape markup in "formatResults()" I'll need to override "escapeMarkup()" from select2 to disable escaping... else it will double escape. Is that what we want ?

select2 still needs a separator to be able to parse the initial value from the hidden "input" field and also to be able to store the values back there.

@PVince81
Copy link
Contributor Author

The format of "exclude groups" in the config is currently comma separated.
If I change it I'll need to change the sharing code as well.
As this is blowing this PR out of proportions, I'll fix it separately first, then merge, then continue this one here.

@PVince81
Copy link
Contributor Author

Raised comma=>json task as #10983

Added explicit escaping.
Now internally using a pipe symbol as separator for select2, to make it
possible to use group names containing commas.
@PVince81
Copy link
Contributor Author

To avoid having to make complex changes that affect other parts of ownCloud I settled on using a pipe symbol internally to make it work with select2.
So for now:

  1. I fixed the XSS issue with explicit escaping
  2. Groups with commas now work on the apps page because it already uses JSON internally
  3. Groups with comma will not work on the "exclude groups from sharing" because it does not use JSON internally: should be addressed as part of Exclude with groups cannot work with groups containing commas #10983
  4. Groups with pipe will cause trouble, but I expect such to not be a common use case. Select2 doesn't work with a JSON structure and requires a comma (or other) separated list of values. I won't patch select2.
  5. I'm not getting any 500 error for appconfig.php, possibly fixed.

Please review/try again.
Thanks.

@ghost
Copy link

ghost commented Sep 10, 2014

💣 Test Failed. 💣
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org/job/pull-request-analyser/7190/

@LukasReschke
Copy link
Member

👍

@th3fallen Please review. Thanks!

@PVince81
Copy link
Contributor Author

Also @owncloud/designers please confirm that it looks ok UX-wise

@jancborchardt
Copy link
Member

I fixed the select box style to fit into the ownCloud style. @owncloud/designers please review.

@ghost
Copy link

ghost commented Sep 10, 2014

💣 Test Failed. 💣
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org/job/pull-request-analyser/7204/

To avoid making a server request every time the dropdown opens, the
whole list of groups are cached (from the last request):

Whenever the user types in a search term it will still send server
requests.
@scrutinizer-notifier
Copy link

A new inspection was created.

@PVince81
Copy link
Contributor Author

I was worried that select2 was making too many ajax requests so I've added a local JS cache that contains all groups. This way when opening the dropdown again it will not redo the request.

However if you type in search terms it will make ajax requests (uncached).

@craigpg craigpg modified the milestones: 2014-sprint-04-current, 2014-sprint-03 Sep 15, 2014
@PVince81
Copy link
Contributor Author

@blizzz I saw in some other issue/PR related to the share autocomplete (the one that returns only 15 entries) that it is not good to use the $search argument.
This PR here also uses the search when the user types in a group name.

Do you think that issue would apply here as well ?

@blizzz
Copy link
Contributor

blizzz commented Sep 16, 2014

I have not seen a corresponding line here, or is it included in /settings/ajax/grouplist? In general yes, the group backend cannot properly search users, only user backends can. We should look into a more general solution for it.

@PVince81
Copy link
Contributor Author

@blizzz I haven't checked the backend code, am just using this endpoint and but the search seems to work. So it's probably filtered by our own code, not the backend ?

@blizzz
Copy link
Contributor

blizzz commented Sep 17, 2014

On a second glance i don't see that users are search for at all, also not in settings/ajax/grouplist. Searching groups using the group backend is of course totally correct.

@PVince81
Copy link
Contributor Author

@blizzz if you don't see anything against this ticket then we can merge it ?

@blizzz
Copy link
Contributor

blizzz commented Sep 19, 2014

reviewed and tested 👍

@blizzz
Copy link
Contributor

blizzz commented Sep 19, 2014

@owncloud-bot retest this please

@ghost
Copy link

ghost commented Sep 19, 2014

🚀 Test Passed. 🚀
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org/job/pull-request-analyser/7475/

LukasReschke added a commit that referenced this pull request Sep 19, 2014
Use select2 for the groups excluded from sharing in admin page
@LukasReschke LukasReschke merged commit fed8100 into master Sep 19, 2014
@LukasReschke LukasReschke deleted the admin-groupsselect2 branch September 19, 2014 14:50
@LukasReschke
Copy link
Member

@karlitschek Another goldy that is crying "Backport me, please!" ;-)

@karlitschek
Copy link
Contributor

yes. please backport

@PVince81
Copy link
Contributor Author

I'm on it.

@PVince81
Copy link
Contributor Author

Backported to stable7 as 97b83b9..c16c680

I also had a quick test and saw that it still works on that branch 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[stable7] Exclude group from shares dropdown broken
8 participants