summary refs log tree commit diff
path: root/synapse/config/room.py
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2020-07-13 17:14:42 +0100
committerGitHub <noreply@github.com>2020-07-13 17:14:42 +0100
commit504c8f3483f3d213b82fa5a81d9cc122f0b465d7 (patch)
tree4a22cf621aae3f9f473ee9e8b34d7dad3b955a68 /synapse/config/room.py
parentUpdate grafana dashboard (diff)
downloadsynapse-504c8f3483f3d213b82fa5a81d9cc122f0b465d7.tar.xz
Fix handling of "off" in encryption_enabled_by_default_for_room_type (#7822)
Fixes https://github.com/matrix-org/synapse/issues/7821, introduced in https://github.com/matrix-org/synapse/pull/7639

Turns out PyYAML translates `off` into a `False` boolean if it's
unquoted (see https://stackoverflow.com/questions/36463531/pyyaml-automatically-converting-certain-keys-to-boolean-values),
which seems to be a liberal interpretation of this bit of the YAML spec: https://yaml.org/spec/1.1/current.html#id864510

An alternative fix would be to implement the solution mentioned in the
SO post linked above, but I'm aware it might break existing setups
(which might use these values in the configuration file) so it's
probably better just to add an extra check for this one. We should be
aware that this is a thing for the next times we do that though.

I didn't find any other occurrence of this bug elsewhere in the
codebase.
Diffstat (limited to '')
-rw-r--r--synapse/config/room.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/synapse/config/room.py b/synapse/config/room.py
index 6aa4de0672..52cf0b62fc 100644
--- a/synapse/config/room.py
+++ b/synapse/config/room.py
@@ -50,7 +50,12 @@ class RoomConfig(Config):
                 RoomCreationPreset.PRIVATE_CHAT,
                 RoomCreationPreset.TRUSTED_PRIVATE_CHAT,
             ]
-        elif encryption_for_room_type == RoomDefaultEncryptionTypes.OFF:
+        elif (
+            encryption_for_room_type == RoomDefaultEncryptionTypes.OFF
+            or encryption_for_room_type is False
+        ):
+            # PyYAML translates "off" into False if it's unquoted, so we also need to
+            # check for encryption_for_room_type being False.
             self.encryption_enabled_by_default_for_room_presets = []
         else:
             raise ConfigError(