-
Notifications
You must be signed in to change notification settings - Fork 67
Enhance media protections #516
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
Conversation
turt2live
left a comment
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.
otherwise lgtm - thanks!
src/protections/MessageIsMedia.ts
Outdated
| if (event['type'] === 'm.room.message') { | ||
| const content = event['content'] || {}; | ||
| let content = event['content'] || {}; | ||
| content = content?.["m.new_content"] ?? content; |
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.
we should probably also check m.relates_to to ensure we're actually looking at an edit here. The risk being that someone decides to send partially malformed events to trick Mjolnir into (dis)allowing something which is still rendered to users.
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.
So we can assume it's an edit if there is both an m.new_content and an m.relates_to field?
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.
m.relates_to can mean many things, but inspecting it should tell us if it's an edit. In practice this means ensuring the m.relates_to rel_type is m.replace, I think. There's a bunch of validity rules we should probably be checking too, but that might still have false negatives if the code isn't perfect (or someone finds a way to send something weird).
turt2live
left a comment
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.
lgtm - thanks!
Co-authored-by: Travis Ralston <travisr@matrix.org>
As the title states.
Fixes #481