Repository navigation
fix: skip encryption for messages without data #748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all 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 |
|---|---|---|
|
|
@@ -131,6 +131,10 @@ def encrypt(self, channel_cipher): | |
| Encrypt the presence message data using the provided cipher. | ||
| Similar to Message.encrypt(). | ||
| """ | ||
| # Presence messages may carry no data, so there is nothing to encrypt. | ||
| if self.data is None: | ||
| return | ||
|
Comment on lines
+135
to
+136
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. Clear encoding when presence data is absent. For
|
||
|
|
||
| if isinstance(self.data, CipherData): | ||
| return | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clear the encoding when
dataisNoneinMessage.encrypt.When
dataisNone, the early return keepsencoding.encode_datathen emitsencodingwithoutdata, so the message is sent as{'name': 'ping', 'encoding': 'base64'}. A receiver that decodes that message callsdecode(None, 'base64'), which raisesAttributeError. Clear the encoding before the return so the message is sent without a payload or encoding.Suggested fix
Committable suggestion