Email-in containing <br></b>


(Leo McArdle) #1

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:

@zogstrip this is your area of expertise, right?


(Leo McArdle) #3

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:


(Robert Hudson) #4

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!


(Gerhard Schlager) #5