-
-
Notifications
You must be signed in to change notification settings - Fork 589
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
Clean up Event.clearEvent handling to fix a bug where malformed events with falsey content wouldn't be considered decrypted #1807
Clean up Event.clearEvent handling to fix a bug where malformed events with falsey content wouldn't be considered decrypted #1807
Conversation
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.
Most of this PR is just me reviewing references to clearEvent
and making sure the code path still behaves if it's now undefined instead of an empty object.
@@ -486,7 +486,7 @@ export class MatrixEvent extends EventEmitter { | |||
} | |||
|
|||
public shouldAttemptDecryption() { | |||
return this.isEncrypted() && !this.isBeingDecrypted() && this.getClearContent() === null; | |||
return this.isEncrypted() && !this.isBeingDecrypted() && !this.clearEvent; |
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.
This is the "fix" here.
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.
Other than the minor nits this is great, thanks!
}).then((event) => { | ||
expect(event.getRoomId()).toEqual(ROOM_ID); | ||
expect(event.getContent()).toEqual({}); | ||
expect(event.getClearContent()).toBeUndefined(); |
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.
This test would fail on develop because getClearContent would continue to be null before and now it actually has the correct(?) value.
Also, testUtils.awaitDecryption
would have thought that the event wasn't decoded yet because getClearContent
would still be null, and therefore would wait for an "Event.decrypted" event that would never come as it was already decrypted.
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.
Great, thanks for this!
Thanks for the feedback and the speedy review! |
shouldAttemptDecryption
was checking to see if we had acontent
property on ourclearEvent
, but it's possible that we've already been decrypted and the result still has a falseycontent
property. Instead, only set theclearEvent
class member after we've successfully decrypted, and leave it undefined otherwise.Signed-off-by: Brad Murray [email protected]