mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-26 03:25:53 +03:00
Fix handling of redacted events from federation
If we receive an event that doesn't pass their content hash check (e.g. due to already being redacted) then we hit a bug which causes an exception to be raised, which then promplty stops the event (and request) from being processed. This effects all sorts of federation APIs, including joining rooms with a redacted state event.
This commit is contained in:
parent
bfa0b759e0
commit
89a76d1889
2 changed files with 6 additions and 1 deletions
|
@ -13,6 +13,8 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from synapse.util.caches import intern_dict
|
from synapse.util.caches import intern_dict
|
||||||
from synapse.util.frozenutils import freeze
|
from synapse.util.frozenutils import freeze
|
||||||
|
|
||||||
|
@ -147,6 +149,9 @@ class EventBase(object):
|
||||||
def items(self):
|
def items(self):
|
||||||
return list(self._event_dict.items())
|
return list(self._event_dict.items())
|
||||||
|
|
||||||
|
def keys(self):
|
||||||
|
return six.iterkeys(self._event_dict)
|
||||||
|
|
||||||
|
|
||||||
class FrozenEvent(EventBase):
|
class FrozenEvent(EventBase):
|
||||||
def __init__(self, event_dict, internal_metadata_dict={}, rejected_reason=None):
|
def __init__(self, event_dict, internal_metadata_dict={}, rejected_reason=None):
|
||||||
|
|
|
@ -153,7 +153,7 @@ class FederationBase(object):
|
||||||
# *actual* redacted copy to be on the safe side.)
|
# *actual* redacted copy to be on the safe side.)
|
||||||
redacted_event = prune_event(pdu)
|
redacted_event = prune_event(pdu)
|
||||||
if (
|
if (
|
||||||
set(six.iterkeys(redacted_event)) == set(six.iterkeys(pdu)) and
|
set(redacted_event.keys()) == set(pdu.keys()) and
|
||||||
set(six.iterkeys(redacted_event.content))
|
set(six.iterkeys(redacted_event.content))
|
||||||
== set(six.iterkeys(pdu.content))
|
== set(six.iterkeys(pdu.content))
|
||||||
):
|
):
|
||||||
|
|
Loading…
Reference in a new issue