From 7ff04be091ce7c75a749feba1ab184869c915e63 Mon Sep 17 00:00:00 2001
From: Michael Gapczynski <mtgap@owncloud.com>
Date: Sat, 28 Jul 2012 11:06:36 -0400
Subject: [PATCH] Correction for 'Fix group detection for sharing in case
 username contains '@', fix for oc-1270'

---
 apps/files_sharing/lib_share.php | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
index 3bedd9bebc..1c061cde07 100644
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -179,10 +179,13 @@ class OC_Share {
 				$uid_shared_with = OC_Group::usersInGroup($uid_shared_with);
 				// Remove the owner from the list of users in the group
 				$uid_shared_with = array_diff($uid_shared_with, array(OCP\USER::getUser()));
-			} else if ($uid = strrchr($uid_shared_with, '@', true)) {
-				$uid_shared_with = array($uid);
 			} else {
-				$uid_shared_with = array($uid_shared_with);
+				$pos = strrpos($uid_shared_with, '@');
+				if ($pos !== false && OC_Group::groupExists(substr($uid_shared_with, $pos + 1))) {
+					$uid_shared_with = array(substr($uid_shared_with, 0, $pos));
+				} else {
+					$uid_shared_with = array($uid_shared_with);
+				}
 			}
 			foreach ($uid_shared_with as $uid) {
 				$sharedFolder = $uid.'/files/Shared';
-- 
GitLab