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

Fix spurious HTML tags being passed through literally #667

Merged
merged 4 commits into from
Feb 2, 2017

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Feb 2, 2017

First 3 commits tidy up code (or just comments) with no functional changes.

Last commit fixes element-hq/element-web#3065 and a couple of other bits as described in the commit message.

Fixes element-hq/element-web#3065

so they don't claim it;s a wrapper around marked when it's now
commonmark, and comment why we render markdown to plaintext which
is somewhat unintuitive.
Rather than re-parsing the same output in each function
Rather than keeping one in memory, abusing it in different ways
each time and then craefully putting it back the way it was (and
in one case, failing, because we forgot to put the `out` method
back).
 * Only render HTML tags in markdown if they're del tags
 * Consider non-allowed HTML tags as plain text nodes, so
   a message of just '<shrug>' doesn't need to be sent as
   HTML
 * Consequently rewrite isPlaintext to just look at the parse
   tree rather than making and gutting a renderer to walk
   the tree (now we're using a library that actually produces
   a meaningfgul parse tree).
 * Tweak when we put \n on text output to avoid putting \n on
   the end of messages.

Fixes element-hq/element-web#3065
@dbkr dbkr requested a review from richvdh February 2, 2017 14:26
Copy link
Member

@richvdh richvdh 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.

I'm concerned about the lack of tests on this. It's exactly the sort of code where it's easy to introduce regressions, so would really benefit from some tests

src/Markdown.js Outdated
const isMultiLine = is_multi_line(node);

if (isMultiLine) this.cr();
html_if_tag_allowed.call(this, node);
Copy link
Member

Choose a reason for hiding this comment

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

is there a reason not to make html_if_tag_allowed a proper member function rather than having to faff with call?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, it would need to be on the node, not the Markdown object.

@richvdh richvdh assigned dbkr and unassigned richvdh Feb 2, 2017
@dbkr
Copy link
Member Author

dbkr commented Feb 2, 2017

Yeah, I was thinking it would also be pretty easy to test. They may have to wait until post-release though.

@dbkr dbkr merged commit 7ae54b3 into develop Feb 2, 2017
@richvdh richvdh deleted the dbkr/fix_markdown_spurious_html branch February 15, 2017 13:16
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.

Messages with <something> in them are sent with spurious HTML tags
2 participants