Embedded links in email-in and reply by emaile

email

(Paul Apostolos) #1

Many times our users will use hyperlinks in their emails. Especially if they are copying and pasting HTML into their email client to reply to a topic or create a new one (via the email-in feature).

The HTML of those hyperlinks typically look like this

You should read this <a href="http://www.somesite.com">Interesting article</a>

That all gets clobbered in the conversion from email to markdown and it can end up looking quite terrible.

Short of telling 1,000 “get-off-my-lawn” users not to do that and causing an uprising, is there anything that can be done through settings to change that behavior?


(Jeff Atwood) #2

That HTML is supported in Markdown though. Can you provide a specific example with raw from the email and resulting post?


(Paul Apostolos) #3

From looking at the raw, it looks like it is pulling the Plain Text version of the email to parse. I used Outlook to send the message and I have included screen shots from the Gmail inbox and the Discourse output. Finally I included the relevant raw portion of the email (Gmail->show original). Obviously, Outlook is terrible at producing clean HTML, but it is widely used

Content-Type: multipart/alternative;
boundary="_000_fad69fb8cd114d3bb23e619b1ebe61f6BLUPR04MB578namprd04pro_"
MIME-Version: 1.0
Return-Path:myaddress@mydomain.com
X-OriginatorOrg: mydomain.com

--_000_fad69fb8cd114d3bb23e619b1ebe61f6BLUPR04MB578namprd04pro_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I would like to test the HTML linking<http://meta.discourse.org/> of email =
in topics.

Hopefully it works.



--_000_fad69fb8cd114d3bb23e619b1ebe61f6BLUPR04MB578namprd04pro_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri","sans-serif";}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">I would like to test the <a href=3D"http://meta.disc=
ourse.org/">
HTML linking</a> of email in topics.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Hopefully it works.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

--_000_fad69fb8cd114d3bb23e619b1ebe61f6BLUPR04MB578namprd04pro_--

(Eyal Levin) #4

I have the same problem.

Looking at the source it seems that the email text_part is the only one being handled (at least from the gmail messages I checked) and the html_part which has the href formatting never gets hit.

But even if the html_part will be handled, at line 94 it looks to be stripped down from html attributes including the link.

I don’t mind trying to fix this but I’ll need some direction on the required logic.

Thanks

@riking


(Kane York) #5

I have fixed this so that the HTML section is considered first and cleaned up - would love to have more testing on it!

At the moment, it cleans up some of the HTML then treats the rest as if you pasted it in the editor.