Skip to content

Commit

Permalink
Make sure the minimum number of characters is used when searching
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Apr 3, 2018
1 parent fd25496 commit cc31af1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/ajax/share.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,18 @@ function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
if (isset($_GET['search'])) {
$cm = OC::$server->getContactsManager();

$userEnumerationAllowed = OC::$server->getConfig()
->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') == 'yes';
$config = OC::$server->getConfig();
$userEnumerationAllowed = $config
->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
$pattern = (string)$_GET['search'];
$searchConfig = new \OCP\Util\UserSearch($config);
if (!$searchConfig->isSearchable($pattern)) {
OC_JSON::error();
return;
}

if ($cm !== null && $cm->isEnabled() && $userEnumerationAllowed) {
$contacts = $cm->search((string)$_GET['search'], ['FN', 'EMAIL']);
$contacts = $cm->search($pattern, ['FN', 'EMAIL']);
foreach ($contacts as $contact) {
// We don't want contacts from system address books
if (isset($contact['isSystemBook'])) {
Expand Down

0 comments on commit cc31af1

Please sign in to comment.