mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Merge pull request #2859 from techAPJ/patch-1
FIX: handle multiple paragraphs in email reply when parsing html
This commit is contained in:
commit
a059da5d39
4 changed files with 218 additions and 2 deletions
|
@ -76,7 +76,7 @@ module Email
|
|||
def add_newlines(doc)
|
||||
# Replace <br> tags with a markdown \n
|
||||
doc.xpath('//br').each do |br|
|
||||
br.replace(new_linebreak_node doc)
|
||||
br.replace(new_linebreak_node doc, 2)
|
||||
end
|
||||
# Surround <p> tags with newlines, to help with line-wise postprocessing
|
||||
# and ensure markdown paragraphs
|
||||
|
|
|
@ -82,6 +82,17 @@ Thanks for listening."
|
|||
)
|
||||
end
|
||||
|
||||
it "handles multiple paragraphs when parsing html" do
|
||||
test_parse_body(fixture_file("emails/html_paragraphs.eml")).
|
||||
should == (
|
||||
"Awesome!
|
||||
|
||||
Pleasure to have you here!
|
||||
|
||||
:boom:"
|
||||
)
|
||||
end
|
||||
|
||||
it "converts back to UTF-8 at the end" do
|
||||
result = test_parse_body(fixture_file("emails/big5.eml"))
|
||||
result.encoding.should == Encoding::UTF_8
|
||||
|
|
205
spec/fixtures/emails/html_paragraphs.eml
vendored
Normal file
205
spec/fixtures/emails/html_paragraphs.eml
vendored
Normal file
|
@ -0,0 +1,205 @@
|
|||
|
||||
MIME-Version: 1.0
|
||||
Received: by 10.25.161.144 with HTTP; Tue, 7 Oct 2014 22:17:17 -0700 (PDT)
|
||||
X-Originating-IP: [117.207.85.84]
|
||||
In-Reply-To: <5434c8b52bb3a_623ff09fec70f049749@discourse-app.mail>
|
||||
References: <topic/35@discourse.techapj.com>
|
||||
<5434c8b52bb3a_623ff09fec70f049749@discourse-app.mail>
|
||||
Date: Wed, 8 Oct 2014 10:47:17 +0530
|
||||
Delivered-To: arpit@techapj.com
|
||||
Message-ID: <CAOJeqne=SJ_LwN4sb-0Y95ejc2OpreVhdmcPn0TnmwSvTCYzzQ@mail.gmail.com>
|
||||
Subject: Re: [Discourse] [Meta] Welcome to techAPJ's Discourse!
|
||||
From: Arpit Jalan <arpit@techapj.com>
|
||||
To: Discourse <mail+e1c7f2a380e33840aeb654f075490bad@arpitjalan.com>
|
||||
Content-Type: multipart/alternative; boundary=001a114119d8f4e46e0504e26d5b
|
||||
|
||||
--001a114119d8f4e46e0504e26d5b
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
|
||||
Awesome!
|
||||
|
||||
Pleasure to have you here!
|
||||
|
||||
:boom:
|
||||
|
||||
On Wed, Oct 8, 2014 at 10:46 AM, ajalan <info@unconfigured.discourse.org>
|
||||
wrote:
|
||||
|
||||
> ajalan
|
||||
> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
|
||||
JzIjoiVXgxTTZ3eHpuRWF2QXVoZGRJZVN5MWI0WnhrIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
|
||||
TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
|
||||
XFxcL3VzZXJzXFxcL2FqYWxhblwiLFwiaWRcIjpcIjgyNWI5MDYzZWNmMDRkMjk5OTE4Nzk1MmU=
|
||||
5YjY2YjE3XCIsXCJ1cmxfaWRzXCI6W1wiNzA3MTNjNTg4MDI3YWQyM2RiM2QwOTVhOGQwYmY4ZT=
|
||||
YyMzNjYThiMFwiXX0ifQ>
|
||||
> October 8
|
||||
>
|
||||
> Nice to be here! Thanks! [image: smile]
|
||||
>
|
||||
> To respond, reply to this email or visit
|
||||
> http://discourse.techapj.com/t/welcome-to-techapjs-discourse/35/2
|
||||
> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
|
||||
JzIjoid1IyWnVqVGRPU2RwLUlFR0Q5QnI1a203eVNjIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
|
||||
TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
|
||||
XFxcL3RcXFwvd2VsY29tZS10by10ZWNoYXBqcy1kaXNjb3Vyc2VcXFwvMzVcXFwvMlwiLFwiaWR=
|
||||
cIjpcIjgyNWI5MDYzZWNmMDRkMjk5OTE4Nzk1MmU5YjY2YjE3XCIsXCJ1cmxfaWRzXCI6W1wiY2=
|
||||
RkYzFlZjc5OThhNzE1ODA4Yjg0MGFlNzVlZmNiYmYzYmViODk4Y1wiXX0ifQ>
|
||||
> in your browser.
|
||||
> ------------------------------
|
||||
> Previous Replies techAPJ
|
||||
> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
|
||||
JzIjoia2x3LUxac2RSX25uWEFYYWcwVDVha3pIY3RjIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
|
||||
TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
|
||||
XFxcL3VzZXJzXFxcL3RlY2hhcGpcIixcImlkXCI6XCI4MjViOTA2M2VjZjA0ZDI5OTkxODc5NTJ=
|
||||
lOWI2NmIxN1wiLFwidXJsX2lkc1wiOltcIjk2ZjAyMzVhNmM2NzIyNmU1NjhhMzU1NDE1OTAxNz=
|
||||
AyYTkxNjM1NzJcIl19In0>
|
||||
> October 8
|
||||
>
|
||||
> Welcome to techAPJ's Discourse!
|
||||
> ------------------------------
|
||||
>
|
||||
> To respond, reply to this email or visit
|
||||
> http://discourse.techapj.com/t/welcome-to-techapjs-discourse/35/2
|
||||
> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
|
||||
JzIjoid1IyWnVqVGRPU2RwLUlFR0Q5QnI1a203eVNjIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
|
||||
TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
|
||||
XFxcL3RcXFwvd2VsY29tZS10by10ZWNoYXBqcy1kaXNjb3Vyc2VcXFwvMzVcXFwvMlwiLFwiaWR=
|
||||
cIjpcIjgyNWI5MDYzZWNmMDRkMjk5OTE4Nzk1MmU5YjY2YjE3XCIsXCJ1cmxfaWRzXCI6W1wiY2=
|
||||
RkYzFlZjc5OThhNzE1ODA4Yjg0MGFlNzVlZmNiYmYzYmViODk4Y1wiXX0ifQ>
|
||||
> in your browser.
|
||||
>
|
||||
> To unsubscribe from these emails, visit your user preferences
|
||||
> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
|
||||
JzIjoiVTNudkpobl9lUUl0cmdsVVRrcm5iaHpyN0JZIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
|
||||
TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
|
||||
XFxcL215XFxcL3ByZWZlcmVuY2VzXCIsXCJpZFwiOlwiODI1YjkwNjNlY2YwNGQyOTk5MTg3OTU=
|
||||
yZTliNjZiMTdcIixcInVybF9pZHNcIjpbXCI0OTIyMmMyZDgyNzUwMmQyMGZjYzU4MTZkNjhmYT=
|
||||
k3NzFkY2YzZDllXCJdfSJ9>
|
||||
> .
|
||||
>
|
||||
|
||||
--001a114119d8f4e46e0504e26d5b
|
||||
Content-Type: text/html; charset=UTF-8
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
|
||||
<div dir=3D"ltr">Awesome!<div><br></div><div>Pleasure to have you here!</di=
|
||||
v><div><br></div><div>:boom:</div></div><div class=3D"gmail_extra"><br><div=
|
||||
class=3D"gmail_quote">On Wed, Oct 8, 2014 at 10:46 AM, ajalan <span dir=3D=
|
||||
"ltr"><<a href=3D"mailto:info@unconfigured.discourse.org" target=3D"_bla=
|
||||
nk">info@unconfigured.discourse.org</a>></span> wrote:<br><blockquote cl=
|
||||
ass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;p=
|
||||
adding-left:1ex"><div>
|
||||
|
||||
<table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cellp=
|
||||
adding=3D"0" border=3D"0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style=3D"vertical-align:top;width:55px">
|
||||
<img src=3D"http://discourse.techapj.com/user_avatar/discourse.tech=
|
||||
apj.com/ajalan/45/35.png" title=3D"ajalan" style=3D"max-width:694px" width=
|
||||
=3D"45" height=3D"45">
|
||||
</td>
|
||||
<td>
|
||||
<a href=3D"http://mandrillapp.com/track/click/30081177/discourse.te=
|
||||
chapj.com?p=3DeyJzIjoiVXgxTTZ3eHpuRWF2QXVoZGRJZVN5MWI0WnhrIiwidiI6MSwicCI6I=
|
||||
ntcInVcIjozMDA4MTE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNl=
|
||||
LnRlY2hhcGouY29tXFxcL3VzZXJzXFxcL2FqYWxhblwiLFwiaWRcIjpcIjgyNWI5MDYzZWNmMDR=
|
||||
kMjk5OTE4Nzk1MmU5YjY2YjE3XCIsXCJ1cmxfaWRzXCI6W1wiNzA3MTNjNTg4MDI3YWQyM2RiM2=
|
||||
QwOTVhOGQwYmY4ZTYyMzNjYThiMFwiXX0ifQ" style=3D"font-size:13px;font-family:&=
|
||||
#39;lucida grande',tahoma,verdana,arial,sans-serif;color:#3b5998;text-d=
|
||||
ecoration:none;font-weight:bold;text-decoration:none;font-weight:bold;color=
|
||||
:#006699" target=3D"_blank">ajalan</a><br>
|
||||
<span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
|
||||
t-family:'lucida grande',tahoma,verdana,arial,sans-serif;font-size:=
|
||||
11px">October 8</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style=3D"padding-top:5px" colspan=3D"2"><p style=3D"margin-top:0;=
|
||||
border:0">Nice to be here! Thanks! <img src=3D"http://discourse.techapj.com=
|
||||
/plugins/emoji/images/smile.png" title=3D":smile:" alt=3D"smile" width=3D"2=
|
||||
0" height=3D"20"></p></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<div style=3D"color:#666">
|
||||
<p>To respond, reply to this email or visit <a href=3D"http://mandrilla=
|
||||
pp.com/track/click/30081177/discourse.techapj.com?p=3DeyJzIjoid1IyWnVqVGRPU=
|
||||
2RwLUlFR0Q5QnI1a203eVNjIiwidiI6MSwicCI6IntcInVcIjozMDA4MTE3NyxcInZcIjoxLFwi=
|
||||
dXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29tXFxcL3RcXFwvd2VsY29=
|
||||
tZS10by10ZWNoYXBqcy1kaXNjb3Vyc2VcXFwvMzVcXFwvMlwiLFwiaWRcIjpcIjgyNWI5MDYzZW=
|
||||
NmMDRkMjk5OTE4Nzk1MmU5YjY2YjE3XCIsXCJ1cmxfaWRzXCI6W1wiY2RkYzFlZjc5OThhNzE1O=
|
||||
DA4Yjg0MGFlNzVlZmNiYmYzYmViODk4Y1wiXX0ifQ" style=3D"color:#666;text-decorat=
|
||||
ion:none;font-weight:bold;color:#006699" target=3D"_blank">http://discourse=
|
||||
.techapj.com/t/welcome-to-techapjs-discourse/35/2</a> in your browser.</p>
|
||||
</div>
|
||||
<hr style=3D"background-color:#ddd;min-height:1px;border:1px;background-c=
|
||||
olor:#ddd;min-height:1px;border:1px">
|
||||
<h4>Previous Replies</h4>
|
||||
|
||||
<table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cel=
|
||||
lpadding=3D"0" border=3D"0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style=3D"vertical-align:top;width:55px">
|
||||
<img src=3D"http://discourse.techapj.com/user_avatar/discourse.tech=
|
||||
apj.com/techapj/45/34.png" title=3D"techAPJ" style=3D"max-width:694px" widt=
|
||||
h=3D"45" height=3D"45">
|
||||
</td>
|
||||
<td>
|
||||
<a href=3D"http://mandrillapp.com/track/click/30081177/discourse.te=
|
||||
chapj.com?p=3DeyJzIjoia2x3LUxac2RSX25uWEFYYWcwVDVha3pIY3RjIiwidiI6MSwicCI6I=
|
||||
ntcInVcIjozMDA4MTE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNl=
|
||||
LnRlY2hhcGouY29tXFxcL3VzZXJzXFxcL3RlY2hhcGpcIixcImlkXCI6XCI4MjViOTA2M2VjZjA=
|
||||
0ZDI5OTkxODc5NTJlOWI2NmIxN1wiLFwidXJsX2lkc1wiOltcIjk2ZjAyMzVhNmM2NzIyNmU1Nj=
|
||||
hhMzU1NDE1OTAxNzAyYTkxNjM1NzJcIl19In0" style=3D"font-size:13px;font-family:=
|
||||
'lucida grande',tahoma,verdana,arial,sans-serif;color:#3b5998;text-=
|
||||
decoration:none;font-weight:bold;text-decoration:none;font-weight:bold;colo=
|
||||
r:#006699" target=3D"_blank">techAPJ</a><br>
|
||||
<span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
|
||||
t-family:'lucida grande',tahoma,verdana,arial,sans-serif;font-size:=
|
||||
11px">October 8</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style=3D"padding-top:5px" colspan=3D"2"><p style=3D"margin-top:0;=
|
||||
border:0">Welcome to techAPJ's Discourse!</p></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<hr style=3D"background-color:#ddd;min-height:1px;border:1px;background-col=
|
||||
or:#ddd;min-height:1px;border:1px">
|
||||
|
||||
<div style=3D"color:#666">
|
||||
<p>To respond, reply to this email or visit <a href=3D"http://mandrillapp.c=
|
||||
om/track/click/30081177/discourse.techapj.com?p=3DeyJzIjoid1IyWnVqVGRPU2RwL=
|
||||
UlFR0Q5QnI1a203eVNjIiwidiI6MSwicCI6IntcInVcIjozMDA4MTE3NyxcInZcIjoxLFwidXJs=
|
||||
XCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29tXFxcL3RcXFwvd2VsY29tZS1=
|
||||
0by10ZWNoYXBqcy1kaXNjb3Vyc2VcXFwvMzVcXFwvMlwiLFwiaWRcIjpcIjgyNWI5MDYzZWNmMD=
|
||||
RkMjk5OTE4Nzk1MmU5YjY2YjE3XCIsXCJ1cmxfaWRzXCI6W1wiY2RkYzFlZjc5OThhNzE1ODA4Y=
|
||||
jg0MGFlNzVlZmNiYmYzYmViODk4Y1wiXX0ifQ" style=3D"color:#666;text-decoration:=
|
||||
none;font-weight:bold;color:#006699" target=3D"_blank">http://discourse.tec=
|
||||
hapj.com/t/welcome-to-techapjs-discourse/35/2</a> in your browser.</p>
|
||||
</div><span class=3D"">
|
||||
<div style=3D"color:#666">
|
||||
<p>To unsubscribe from these emails, visit your <a href=3D"http://mandrilla=
|
||||
pp.com/track/click/30081177/discourse.techapj.com?p=3DeyJzIjoiVTNudkpobl9lU=
|
||||
Ul0cmdsVVRrcm5iaHpyN0JZIiwidiI6MSwicCI6IntcInVcIjozMDA4MTE3NyxcInZcIjoxLFwi=
|
||||
dXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29tXFxcL215XFxcL3ByZWZ=
|
||||
lcmVuY2VzXCIsXCJpZFwiOlwiODI1YjkwNjNlY2YwNGQyOTk5MTg3OTUyZTliNjZiMTdcIixcIn=
|
||||
VybF9pZHNcIjpbXCI0OTIyMmMyZDgyNzUwMmQyMGZjYzU4MTZkNjhmYTk3NzFkY2YzZDllXCJdf=
|
||||
SJ9" style=3D"color:#666;text-decoration:none;font-weight:bold;color:#00669=
|
||||
9" target=3D"_blank">user preferences</a>.</p>
|
||||
</div>
|
||||
</span></div>
|
||||
|
||||
<img src=3D"http://mandrillapp.com/track/open.php?u=3D30081177&id=3D825=
|
||||
b9063ecf04d2999187952e9b66b17" height=3D"1" width=3D"1"></blockquote></div>=
|
||||
<br></div>
|
||||
|
||||
--001a114119d8f4e46e0504e26d5b--
|
2
spec/fixtures/emails/paragraphs.eml
vendored
2
spec/fixtures/emails/paragraphs.eml
vendored
|
@ -39,4 +39,4 @@ On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta
|
|||
> Please visit this link to respond: http://localhost:3000/t/adventure-time-sux/1234/3
|
||||
>
|
||||
> To unsubscribe from these emails, visit your [user preferences](http://localhost:3000/user_preferences).
|
||||
>
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue