-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Always allow the empty string as an avatar_url. #12261
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix a bug introduced in Synapse 1.52 where admins could not deactivate and GDPR-eerase a user if Synapse was configured with limits on avatars. | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -336,12 +336,18 @@ async def check_avatar_size_and_mime_type(self, mxc: str) -> bool: | |||||||||||||||||||||||||||
| """Check that the size and content type of the avatar at the given MXC URI are | ||||||||||||||||||||||||||||
| within the configured limits. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| If the given `mxc` is empty, no checks are performed. (Users are always able to | ||||||||||||||||||||||||||||
| unset their avatar.) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Args: | ||||||||||||||||||||||||||||
| mxc: The MXC URI at which the avatar can be found. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Returns: | ||||||||||||||||||||||||||||
| A boolean indicating whether the file can be allowed to be set as an avatar. | ||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||
| if mxc == "": | ||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that you might be able to get a non-string value into here via
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The avatar_url must have a synapse/synapse/handlers/room_member.py Line 618 in 8533c8b
And given that it comes from JSON, that means that But this isn't the first unverified body parameter. Frankly I'd just toss this one in the #8445 bucket.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previoulsy a JSON
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh sorry, you're quite right (I didn't spot the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the proper solution might be to do
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I sympathise, but I'm mainly interested in fixing #12257 here. The worst that happens today when going via the RoomMember path is an internal server error when a client gives us a garbage A little more context: when trying to deactivate+erase a user, we set their avatar_url to synapse/synapse/handlers/deactivate_account.py Lines 149 to 151 in 15382b1
And that ends up failing if avatar restrictions are turned on.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this should handle blank strings properly, but it seems silly to not also handle the other data while we're here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not following you here---what other data you have in mind? Would you prefer
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm suggesting to add additional handling to raise errors if the value is not a string and not None, similar to what we do at synapse/synapse/handlers/profile.py Lines 296 to 304 in 300ed0b
Although that case seems to be rejecting strings... /me sighs. I'm not sure what the behavior of this code is supposed to be (should it accept nulls or not). Maybe we should just accept this as is.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Nor I; if it were up to me we'd reject nulls here. |
||||||||||||||||||||||||||||
| return True | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if not self.max_avatar_size and not self.allowed_avatar_mimetypes: | ||||||||||||||||||||||||||||
| return True | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.