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

Commit

Permalink
Fix redacted events being returned in search results ordered by "rece…
Browse files Browse the repository at this point in the history
…nt" (#6522)
  • Loading branch information
anoadragon453 authored Dec 12, 2019
1 parent 25f1244 commit 5bfd885
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit 5bfd885

Please sign in to comment.