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

Show diff for formatted messages in the edit history #3244

Merged
merged 1 commit into from
Jul 24, 2019

Conversation

bwindels
Copy link
Contributor

@bwindels bwindels commented Jul 24, 2019

Implements last bit of element-hq/element-web#9493

The way it works is by first diffing the html tree, and for text nodes that changed, still do the diff-match-patch library we were already using before for plain text diffs.

Diffs are applied to a DOM tree from parsing the base message.

On point of attention is avoiding XSS attacks here. I've taking care to avoid this, but would be a good point to focus on during review.

This adds a dependency (dom-diff) of about 27K.

Some screenshots, plain text diffs still working:
image

Making sure text doesn't get interpreted as HTML:
image

More elaborate example with block elements:
image

@bwindels bwindels requested a review from a team July 24, 2019 09:35
@bwindels bwindels changed the title Implement diffing html messages in the edit history Diff formatted messages in the edit history Jul 24, 2019
@bwindels bwindels changed the title Diff formatted messages in the edit history Show diff for formatted messages in the edit history Jul 24, 2019
@dbkr dbkr requested review from dbkr and removed request for a team July 24, 2019 09:41
Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine - you're sanitising both chunks of html before any diffing happens, so should be fine from an XSS perspective.

@bwindels bwindels merged commit ac31b4b into develop Jul 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants