Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix redacted events being returned in search results ordered by "recent" #6522

Merged
merged 2 commits into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6522.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent redacted events from being returned during message search.
11 changes: 8 additions & 3 deletions synapse/storage/data_stores/main/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def search_msgs(self, room_ids, search_term, keys):
"""
clauses = []

search_query = search_query = _parse_query(self.database_engine, search_term)
search_query = _parse_query(self.database_engine, search_term)

args = []

Expand Down Expand Up @@ -501,7 +501,7 @@ def search_rooms(self, room_ids, search_term, keys, limit, pagination_token=None
"""
clauses = []

search_query = search_query = _parse_query(self.database_engine, search_term)
search_query = _parse_query(self.database_engine, search_term)

args = []

Expand Down Expand Up @@ -606,7 +606,12 @@ def search_rooms(self, room_ids, search_term, keys, limit, pagination_token=None

results = list(filter(lambda row: row["room_id"] in room_ids, results))

events = yield self.get_events_as_list([r["event_id"] for r in results])
# We set redact_behaviour to BLOCK here to prevent redacted events being returned in
# search results (which is a data leak)
events = yield self.get_events_as_list(
[r["event_id"] for r in results],
redact_behaviour=EventRedactBehaviour.BLOCK,
)

event_map = {ev.event_id: ev for ev in events}

Expand Down