Skip to content

Commit 1696e9b

Browse files
committed
Fix leak of invisible participants in conversation dropdown
ref https://www.woltlab.com/community/thread/310591
1 parent d84571c commit 1696e9b

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

files/lib/data/conversation/Conversation.class.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public function getParticipantIDs($excludeLeftParticipants = false)
382382
* @param bool $leftByOwnChoice
383383
* @return string[]
384384
*/
385-
public function getParticipantNames($excludeSelf = false, $leftByOwnChoice = false)
385+
public function getParticipantNames($excludeSelf = false, $leftByOwnChoice = false, bool $isAuthor = false)
386386
{
387387
$conditions = new PreparedStatementConditionBuilder();
388388
$conditions->add("conversationID = ?", [$this->conversationID]);
@@ -392,6 +392,9 @@ public function getParticipantNames($excludeSelf = false, $leftByOwnChoice = fal
392392
if ($leftByOwnChoice) {
393393
$conditions->add("conversation_to_user.leftByOwnChoice = ?", [1]);
394394
}
395+
if (!$isAuthor) {
396+
$conditions->add("conversation_to_user.isInvisible = ?", [0]);
397+
}
395398

396399
$sql = "SELECT user_table.username
397400
FROM wcf" . WCF_N . "_conversation_to_user conversation_to_user

files/lib/data/conversation/ConversationAction.class.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -919,9 +919,7 @@ public function getConversations(): array
919919
} else {
920920
if ($conversation->participants > 1) {
921921
$image = '<span class="icon icon48 fa-users"></span>';
922-
$usernames = \array_filter($conversation->getParticipantNames(), static function ($username) use ($conversation) {
923-
return $username !== $conversation->getUserProfile()->username;
924-
});
922+
$usernames = $conversation->getParticipantNames(true);
925923
} else {
926924
$image = $conversation->getUserProfile()->getAvatar()->getImageTag(48);
927925
$usernames = [$conversation->getUserProfile()->username];
@@ -1002,7 +1000,11 @@ public function getAddParticipantsForm()
10021000
}
10031001

10041002
return [
1005-
'excludedSearchValues' => $this->conversation->getParticipantNames(false, true),
1003+
'excludedSearchValues' => $this->conversation->getParticipantNames(
1004+
false,
1005+
true,
1006+
$this->conversation->userID == WCF::getUser()->userID
1007+
),
10061008
'maxItems' => WCF::getSession()->getPermission('user.conversation.maxParticipants') - $this->conversation->participants,
10071009
'canAddGroupParticipants' => WCF::getSession()->getPermission('user.conversation.canAddGroupParticipants'),
10081010
'template' => WCF::getTPL()->fetch(

0 commit comments

Comments
 (0)