[Owncloud] usenames containing "@" and sharing

Michael Gapczynski mtgap at owncloud.com
Tue Jul 10 14:12:33 UTC 2012


Sharing is being refactored for the next version of ownCloud. This issue has 
already been resolved.


Michael

On Tuesday, July 10, 2012 04:04:51 PM Holger Angenent wrote:
> Dear ownClouders,
> 
> I recently found out that the sharing module of ownCloud is not capable
> to deal with usernames containing the "@" sign. Especially sharing files
> with groups, which is handled via an @ between the username and the
> group does not really work. Since I want to use email addresses as
> usernames, this is crucial for me.
> 
> Looking at the code, at least two files have to be modified,
> files_sharing/lib_share.php and files_sharing/ajax/getitem.php
> 
> In lib_share.php, the lines:
>                       } else if ($uid = strstr($uid_shared_with, '@',
> true)) {
>                               $uid_shared_with = array($uid);
> 
> could be replaced by something like:
>                         } else if ($uid = strstr($uid_shared_with, '@',
> true)) {
>                                 // string contains @, check, if it is a
> group
>                                 if ($uidPart = strstr($uid, '@', true)) {
>                                         // username contains @ and
> shared with group
>                                         $uid =
> substr($uid_shared_with,0,strrpos($uid_shared_with, '@'));
>                                         $uid_shared_with = array($uid);
>                                 } else {
>                                         // username contains @ or user
> without @ shares with group
>                                         $uidEnd =
> strrchr($uid_shared_with, '@');
>                                         if
> (OC_Group::groupExists($uidEnd)) {
>                                                 // username does not
> contain @, but shares with group
>                                                 $uid_shared_with =
> array($uid);
>                                         } else {
>                                                 // username contains @,
> but does not share with group
>                                                 $uid_shared_with =
> array($uid_shared_with);
>                                         }
>                                 }
> 
> 
> In ajax/getitem.php, instead of
>                                 if (($pos = strpos($uid_shared_with,
> '@')) !== false) {
> 
> you would need something like
>                                 if (($pos = strrpos($uid_shared_with,
> '@')) !== false) {
>                                                 $gid =
> substr($uid_shared_with, $pos + 1);
>                                                 if
> (!isset($item['groups'])) {
>                                                         $item['groups']
> = $group;
>                                                 } else if
> (is_array($item['groups'])) {
>                                                         $gidExists = false;
>                                                         $currentGroups =
> $item['groups'];
>                                                         // Check if the
> group is already included
>                                                         foreach
> ($currentGroups as $g) {
>                                                                 if
> ($g['gid'] == $gid) {
> 
> $gidExists = true;
>                                                                 }
>                                                         }
>                                                 }
>                                         if (!$gidExists) { // check if
> the part after the @ is a group
>                                                 if ($path == $source) {
>                                                         $user =
> array(array('uid' => $uid_shared_with, 'permissions' =>
> $rows[$i]['permissions'], 'parentFolder' => false));
>                                                 } else {
>                                                         $user =
> array(array('uid' => $uid_shared_with, 'permissions' =>
> $rows[$i]['permissions'], 'parentFolder' => basename($path)));
>                                                 }
>                                                 if
> (!isset($item['users'])) {
>                                                         $item['users'] =
> $user;
>                                                 } else if
> (is_array($item['users'])) {
>                                                         $item['users'] =
> array_merge($item['users'], $user);
>                                                 }
>                                         } else {
> 
> I hope, this is still readable. Unfortunately, this still has some
> problems. In the webinterface, the "Shared" folder seems to be empty,
> via webdavs, everything is there.
> By the way, the dropdown menu for sharing is rather small. I would
> appreciate it, if the width in css/sharing.css would be 32em, so long
> usernames sharing files with groups would still remain readable.
> 
> Is anybody able to reproduce this behavior and fix the bug?
> 
> Cheers, Holger



More information about the Owncloud mailing list