Email-in containing <br></b>

We’ve run into this annoying bug a number of times on discourse.mozilla.org, where users will send an email to Discourse and half of the email will go missing for no apparent reason.

The reason is, as it turns out, because whatever email client they’re using has generated html along the lines of this: <b>Some bold text<br></b>.

In lib/email/reciever.rb this html is then turned into this markdown by HtmlToMarkdown:

**Some bold text
**

Then EmailReplyTrimmer comes along, sees ** as a delimiter between body and footer of email, and removes it and everything below it.


I would say the bug here exists in HtmlToMarkdown since the markdown it’s generating isn’t valid:

**Oops
**

So I’ve had a crack at fixing that here:

https://github.com/discourse/discourse/pull/5022

@zogstrip this is your area of expertise, right?

13 Likes

Oops, I didn’t test with all the emails that were having their ends cut off, and found another bug!

<b></b> turns into ****, causing much the same issue.

I’ve added a fix for that to the PR:

https://github.com/discourse/discourse/pull/5022/commits/15bee71ed3e5afb9d200e516796447371839a4a8

6 Likes

I suspect you may have cracked the cause (or one of them) of the issues we’ve been seeing with mailed-in replies losing the majority of their content!

3 Likes