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

Commit

Permalink
Fix handling of "off" in encryption_enabled_by_default_for_room_type (#…
Browse files Browse the repository at this point in the history
…7822)

Fixes #7821, introduced in #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.
  • Loading branch information
babolivier authored Jul 13, 2020
1 parent fa361c8 commit 504c8f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/7822.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug causing Synapse to misinterpret the value `off` for `encryption_enabled_by_default_for_room_type` in its configuration file(s) if that value isn't surrounded by quotes. This bug was introduced in v1.16.0.
7 changes: 6 additions & 1 deletion synapse/config/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ def read_config(self, config, **kwargs):
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(
Expand Down

0 comments on commit 504c8f3

Please sign in to comment.