gmailgem / gmail

A Rubyesque interface to Gmail, with all the tools you'll need.
Other
397 stars 119 forks source link

Unpredictable `=\r\n` around all text #193

Closed asiniy closed 9 years ago

asiniy commented 9 years ago

Hey!

I want to fetch html code of incoming gmail messages to parse via nokogiri gem. That's how I use it:

email = @gmail_account.mailbox(label.name).find(:unread).first
email.message.html_part.body.raw_source # => What do I get?
<div dir=3D\"ltr\"><div class=3D\"gmail_quote\"><br><br><u></u>        <div>   =\r\n <img src=3D\"http://apply.naukri.com/apply/amrTracking?applyId=3D4753314885=\r\n&amp;relScore=3D21&amp;starRating=3D1\" height=3D\"0\" width=3D\"0\"> <table wid=\r\nth=3D\"100%\" border=3D\"0\" cellspacing=3D\"0\" cellpadding=3D\"0\"> <tbody><tr> <=\r\ntd bgcolor=3D\"#f8f8f8\" height=3D\"8\"><img src=3D\"http://static.naukimg.com/s=\r\n/1/107//i/spacer.gif\" width=3D\"1\" height=3D\"8\" vspace=3D\"0\" hspace=3D\"0\" al=\r\nign=3D\"left\"></td> </tr> </tbody></table>=20\r\n              <table width=3D\"100%\" border=3D\"0\" cellspacing=3D\"0\" cellpadd=\r\ning=3D\"0\" bgcolor=3D\"#f2f2f2\"> <tbody><tr> <td><table border=3D\"0\" cellspac=\r\ning=3D\"0\" cellpadding=3D\"0\" align=3D\"center\" style=3D\"max-width:600px\"> <tb=\r\nody><tr> <td width=3D\"16\"><img src=3D\"http://static.naukimg.com/s/1/107//i/=\r\nspacer.gif\" width=3D\"10\" height=3D\"1\" vspace=3D\"0\" hspace=3D\"0\" align=3D\"le=\r\nft\"></td> <td width=3D\"568\" valign=3D\"top\"><table border=3D\"0\" cellspacing=\r\n=3D\"0\" cellpadding=3D\"0\" style=3D\"max-width:568px\"> <tbody><tr> <td colspan=\r\n=3D\"2\" valign=3D\"top\"><table width=3D\"298\" border=3D\"0\" cellspacing=3D\"0\" c=\r\nellpadding=3D\"0\" align=3D\"right\"> <tbody><tr> <td align=3D\"center\"><img src=\r\n=3D\"http://static.naukimg.com/s/1/107//i/naukrirmj_logo.gif\" alt=3D\" test\" =\r\nwidth=3D\"298\" height=3D\"50\" hspace=3D\"0\" vspace=3D\"0\" border=3D\"0\" align=3D=\r\n\"right\" style=3D\"background-color:#f8f8f8\"></td> </tr> </tbody></table> </t=\r\nd> </tr> <tr> <td width=3D\"284\" height=3D\"24\"></td> <td width=3D\"284\"></td>=\r\n </tr> <tr> <td colspan=3D\"2\" valign=3D\"top\"><table border=3D\"0\" cellspacin=\r\ng=3D\"0\" cellpadding=3D\"0\" style=3D\"max-width:560px\"> <tbody><tr> <td width=\r\n=3D\"560\" style=3D\"font-family:Arial,Helvetica,sans-serif;font-size:14px;col=\r\nor:#303030\">Dear Recruiter,</td> </tr> <tr> <td height=3D\"18\"></td> </tr> <=\r\ntr> <td style=3D\"font-family:Arial,Helvetica,sans-serif;font-size:14px;colo=\r\nr:#303030\"> Jenne Obilesu  <strong>applied to the Job =E2=80=9C<a href=3D\"h=\r\nttp://jobsearch.naukri.com/job-listings--Flipkart-Node-js-mongodb-Developer=\r\n-Flipkart-Mumbai-Bengaluru-Bangalore-Delhi-NCR-National-Capital-Region-Chen=\r\nnai-Pune-Hyderabad-Secunderabad-Chandigarh-Davangere-1-to-6-years-270915000=\r\n532\" title=3D\"Flipkart - Node.js/mongodb Developer\" style=3D\"text-decoratio=\r\nn:none;color:#0e7dcb;font-family:Arial,Helvetica,sans-serif;font-size:14px;=\r\ntext-decoration:none\" target=3D\"_blank\">Flipkart - Node.js/mongodb Develope=\r\nr</a>=E2=80=9D</strong></td> </tr> <tr> <td height=3D\"10\"></td> </tr> <tr> =\r\n<td valign=3D\"top\">  <table width=3D\"171\" border=3D\"0\" cellspacing=3D\"0\" ce=\r\nllpadding=3D\"0\" align=3D\"left\"> <tbody><tr> <td width=3D\"3\" height=3D\"32\"><=\r\nimg src=3D\"http://static.naukimg.com/s/1/107//i/left_blue_bg_link.jpg\" widt=\r\nh=3D\"3\" height=3D\"32\" vspace=3D\"0\" hspace=3D\"0\" align=3D\"left\"></td> <td wi=\r\ndth=3D\"158\" background=3D\"http://static.naukimg.com/s/1/107//i/blue_bg_link=\r\n.jpg\" bgcolor=3D\"#1b89dd\" align=3D\"center\"><a href=3D\"http://response.test.=\r\ncom?file=3D270915000532\" title=3D\"View all responses\" style=3D\"color:#f8f8f=\r\n8;font-family:Arial,Helvetica,sans-serif;font-size:15px;text-decoration:non=\r\ne;display:block;line-height:30px\" target=3D\"_blank\">View all responses</a><=\r\n/td> <td width=3D\"3\"><img src=3D\"http://static.naukimg.com/s/1/107//i/right=\r\n_blue_bg_link.jpg\" width=3D\"3\" height=3D\"32\" vspace=3D\"0\" hspace=3D\"0\" alig=\r\nn=3D\"left\"></td> <td width=3D\"7\"></td> </tr> <tr> <td height=3D\"8\"></td> <t=\r\nd></td> </tr> </tbody></table>   </td> </tr> <tr> <td style=3D\"font-family:=\r\nArial,Helvetica,sans-serif;font-size:14px;color:#303030\">   Please find the=\r\n profile summary of the applicant below and the detailed resume attached to=\r\n this email.</td> </tr> <tr> <td height=3D\"20\"></td> </tr>  <tr> <td height=\r\n=3D\"16\"></td> <td></td> </tr> <tr> <td valign=3D\"top\"><table border=3D\"0\" c=\r\nellspacing=3D\"0\" cellpadding=3D\"0\" align=3D\"center\" bgcolor=3D\"#ffffff\" sty=\r\nle=3D\"max-width:568px;border:1px #e8e8e8 solid\"> <tbody><tr> <td width=3D\"1=\r\n2\"><img src=3D\"http://static.naukimg.com/s/1/107//i/spacer.gif\" width=3D\"5\"=\r\n height=3D\"1\" vspace=3D\"0\" hspace=3D\"0\" align=3D\"left\"></td> <td width=3D\"5=\r\n32\" valign=3D\"top\"><table border=3D\"0\" cellspacing=3D\"0\" cellpadding=3D\"0\" =\r\nstyle=3D\"max-width:532px;font-family:Arial,Helvetica,sans-serif;font-size:1=\r\n2px;color:#303030\"> <tbody><tr> <td width=3D\"266\" height=3D\"20\"></td> <td w=\r\nidth=3D\"266\"></td> </tr> <tr> <td colspan=3D\"2\" valign=3D\"top\" align=3D\"lef=\r\nt\"><table width=3D\"145\" border=3D\"0\" cellspacing=3D\"0\" cellpadding=3D\"0\" al=\r\nign=3D\"left\"> <tbody><tr> <td width=3D\"135\" style=3D\"font-family:Arial,Helv=\r\netica,sans-serif;font-size:18px;color:#4e4e4e\">Profile Summary</td> <td wid=\r\nth=3D\"3\"></td> <td width=3D\"5\" style=3D\"font-family:Arial,Helvetica,sans-se=\r\nrif;font-size:13px;color:#c8c8c8\">|</td> <td width=3D\"2\"></td> </tr> <tr> <=\r\ntd height=3D\"6\"></td> <td></td> <td></td> </tr> </tbody></table>  <table wi=\r\ndth=3D\"130\" border=3D\"0\" cellspacing=3D\"0\" cellpadding=3D\"0\" align=3D\"left\"=\r\n> <tbody><tr> <td height=3D\"25\"><a href=3D\"http://response.naukri.com/previ=\r\new/show?&amp;file=3D270915000532&amp;resumeId=3D07f975189365da679f565f949b2=\r\nbd21f59ba033e982776d6&amp;src=3Dapply\" title=3D\"View Candidate&#39;s comple=\r\nte profile\" style=3D\"text-decoration:none;color:#0e7dcb;font-family:Arial,H=\r\nelvetica,sans-serif;font-size:13px;text-decoration:none\" target=3D\"_blank\">=\r\nView complete profile</a></td> </tr> <tr> <td height=3D\"5\"></td> </tr> </tb=\r\nody></table>  <table width=3D\"175\" border=3D\"0\" cellspacing=3D\"0\" cellpaddi=\r\nng=3D\"0\" align=3D\"right\"><tbody><tr>\r\n                                  <td width=3D\"28\"></td><td width=3D\"22\"><i=\r\nmg src=3D\"http://static.naukimg.com/s/1/107//i/star_1.gif\" alt=3D\"Resume Ra=\r\nting\" width=3D\"16\" height=3D\"15\" vspace=3D\"0\" hspace=3D\"3\" align=3D\"left\" s=\r\ntyle=3D\"background-color:#ffe157\"></td><td width=3D\"22\"><img src=3D\"http://=\r\nstatic.naukimg.com/s/1/107//i/star_2.gif\" width=3D\"16\" height=3D\"15\" vspace=\r\n=3D\"0\" hspace=3D\"3\" align=3D\"left\" style=3D\"background-color:#bebebe\"></td>=\r\n<td width=3D\"22\"><img src=3D\"http://static.naukimg.com/s/1/107//i/star_2.gi=\r\nf\" width=3D\"16\" height=3D\"15\" vspace=3D\"0\" hspace=3D\"3\" align=3D\"left\" styl=\r\ne=3D\"background-color:#bebebe\"></td><td width=3D\"22\"><img src=3D\"http://sta=\r\ntic.naukimg.com/s/1/107//i/star_2.gif\" width=3D\"16\" height=3D\"15\" vspace=3D=\r\n\"0\" hspace=3D\"3\" align=3D\"left\" style=3D\"background-color:#bebebe\"></td><td=\r\n width=3D\"22\"><img src=3D\"http://static.naukimg.com/s/1/107//i/star_2.gif\" =\r\nwidth=3D\"16\" height=3D\"15\" vspace=3D\"0\" hspace=3D\"3\" align=3D\"left\" style=\r\n=3D\"background-color:#bebebe\"></td><td width=3D\"30\" style=3D\"font-family:Ar=\r\nial,Helvetica,sans-serif;font-size:12px;color:#303030\"><strong>(1/5)</stron=\r\ng></td></tr><tr><td colspan=3D\"7\" height=3D\"25\" style=3D\"font-family:Arial,=\r\nHelvetica,sans-serif;font-size:10px;color:#979797;text-align:right\">Higher =\r\nscore means a better match</td>\r\n                                      </tr></tbody></table></td> </tr> <tr>=\r\n <td height=3D\"2\" colspan=3D\"2\" style=3D\"border-bottom:1px #e5e5e5 solid\"><=\r\n/td> </tr> <tr> <td colspan=3D\"2\"><table border=3D\"0\" cellspacing=3D\"0\" cel=\r\nlpadding=3D\"0\" style=3D\"max-width:532px;font-family:Arial,Helvetica,sans-se=\r\nrif;font-size:12px;color:#303030\"> <tbody><tr> <td colspan=3D\"2\"><table bor=\r\nder=3D\"0\" cellspacing=3D\"0\" cellpadding=3D\"0\" align=3D\"center\" style=3D\"max=\r\n-width:530px;font-family:Arial,Helvetica,sans-serif;font-size:13px;color:#a=\r\n2a1a1\"> <tbody><tr> <td width=3D\"266\" height=3D\"10\"></td> <td width=3D\"266\"=\r\n></td> </tr> <tr> <td width=3D\"172\" valign=3D\"top\">Resume Headline</td> <td=\r\n width=3D\"10\"><img src=3D\"http://static.naukimg.com/s/1/107//i/spacer.gif\" =\r\nwidth=3D\"5\" height=3D\"1\" vspace=3D\"0\" hspace=3D\"0\" align=3D\"left\"></td> <td=\r\n width=3D\"10\" valign=3D\"top\">:</td> <td width=3D\"14\"><img src=3D\"http://sta=\r\ntic.naukimg.com/s/1/107//i/spacer.gif\" width=3D\"5\" height=3D\"1\" vspace=3D\"0=\r\n\" hspace=3D\"0\" align=3D\"left\"></td> <td width=3D\"324\" style=3D\"color:#30303=\r\n0\" valign=3D\"top\">b.tech in electronics and telecommunications..10 months e=\r\nxperiance in BPO as a  CSE.</td> </tr> <tr> <td height=3D\"10\"></td> <td></t=\r\nd> <td></td> <td></td> <td></td> </tr> <tr> <td valign=3D\"top\">Key Skills</=\r\ntd> <td></td> <td valign=3D\"top\">:</td> <td></td> <td valign=3D\"top\" style=\r\n=3D\"color:#303030\">MS Office, Data Entry, Computer Operating,</td> </tr> <t=\r\nr> <td height=3D\"10\"></td> <td></td> <td></td> <td></td> <td></td> </tr> <t=\r\nr> <td valign=3D\"top\">Name</td> <td></td> <td valign=3D\"top\">:</td> <td></t=\r\nd> <td valign=3D\"top\" style=3D\"color:#303030\">Jenne Obilesu</td> </tr> <tr>=\r\n <td height=3D\"10\"></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr>=\r\n <td valign=3D\"top\">Total Experience</td> <td></td> <td valign=3D\"top\">:</t=\r\nd> <td></td> <td valign=3D\"top\" style=3D\"color:#303030\">  1 Year, 3 Months =\r\n </td> </tr> <tr> <td height=3D\"10\"></td> <td></td> <td></td> <td></td> <td=\r\n></td> </tr> <tr> <td valign=3D\"top\">CTC</td> <td></td> <td valign=3D\"top\">=\r\n:</td> <td></td> <td valign=3D\"top\" style=3D\"color:#303030\">   Rs.  1.40 La=\r\nkhs  </td> </tr> <tr> <td height=3D\"10\"></td> <td></td> <td></td> <td></td>=\r\n <td></td> </tr> <tr> <td valign=3D\"top\">Current Employer</td> <td></td> <t=\r\nd valign=3D\"top\">:</td> <td></td> <td valign=3D\"top\" style=3D\"color:#303030=\r\n\">Magus Customer Dialog</td> </tr> <tr> <td height=3D\"10\"></td> <td></td> <=\r\ntd></td> <td></td> <td></td> </tr> <tr> <td valign=3D\"top\">Current Designat=\r\nion</td> <td></td> <td valign=3D\"top\">:</td> <td></td> <td valign=3D\"top\" s=\r\ntyle=3D\"color:#303030\">Corporate Trainer</td> </tr> <tr> <td height=3D\"10\">=\r\n</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td valign=3D\"top\"=\r\n>Last Employer</td> <td></td> <td valign=3D\"top\">:</td> <td></td> <td valig=\r\nn=3D\"top\" style=3D\"color:#303030\">TBSL</td> </tr> <tr> <td height=3D\"10\"></=\r\ntd> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td valign=3D\"top\">L=\r\nast Designation</td> <td></td> <td valign=3D\"top\">:</td> <td></td> <td vali=\r\ngn=3D\"top\" style=3D\"color:#303030\">Technical Support Engineer</td> </tr> <t=\r\nr> <td height=3D\"10\"></td> <td></td> <td></td> <td></td> <td></td> </tr> <t=\r\nr> <td valign=3D\"top\">Current Location</td> <td></td> <td valign=3D\"top\">:<=\r\n/td> <td></td> <td valign=3D\"top\" style=3D\"color:#303030\">  Hyderabad / Sec=\r\nunderabad  </td> </tr> <tr> <td height=3D\"10\"></td> <td></td> <td></td> <td=\r\n></td> <td></td> </tr> <tr> <td valign=3D\"top\">Preferred Location</td> <td>=\r\n</td> <td valign=3D\"top\">:</td> <td></td> <td valign=3D\"top\" style=3D\"color=\r\n:#303030\">  Visakhapatnam  </td> </tr> <tr> <td height=3D\"10\"></td> <td></t=\r\nd> <td></td> <td></td> <td></td> </tr> <tr> <td valign=3D\"top\">Education</t=\r\nd> <td></td> <td valign=3D\"top\">:</td> <td></td> <td valign=3D\"top\" style=\r\n=3D\"color:#303030\">=20\r\nB.Tech/B.E.  </td></tr> <tr> <td height=3D\"10\"></td> <td></td> <td></td> <t=\r\nd></td> <td></td> </tr> <tr> <td valign=3D\"top\">Mobile</td> <td></td> <td v=\r\nalign=3D\"top\">:</td> <td></td> <td valign=3D\"top\" style=3D\"color:#303030\"> =\r\n 8008286773  </td> </tr> <tr> <td height=3D\"10\"></td> <td></td> <td></td> <=\r\ntd></td> <td></td> </tr> <tr> <td valign=3D\"top\">Landline</td> <td></td> <t=\r\nd valign=3D\"top\">:</td> <td></td> <td valign=3D\"top\" style=3D\"color:#303030=\r\n\">  Not Specified  </td> </tr> <tr> <td height=3D\"10\"></td> <td></td> <td><=\r\n/td> <td></td> <td></td> </tr>   </tbody></table></td> </tr> <tr> <td colsp=\r\nan=3D\"2\"></td> </tr> <tr> <td height=3D\"5\" colspan=3D\"2\" style=3D\"border-bo=\r\nttom:1px #e5e5e5 solid\"></td> </tr>  <tr> <td colspan=3D\"2\" height=3D\"5\"></=\r\ntd> </tr> </tbody></table></td> </tr> <tr> <td colspan=3D\"2\"></td> </tr>   =\r\n <tr> <td colspan=3D\"2\" valign=3D\"top\" bgcolor=3D\"#f0f0f0\" style=3D\"border:=\r\n1px #e8e8e8 solid\"><table cellspacing=3D\"0\" cellpadding=3D\"0\" style=3D\"max-=\r\nwidth:532px\"> <tbody><tr> <td width=3D\"10\"><img src=3D\"http://static.naukim=\r\ng.com/s/1/107//i/spacer.gif\" width=3D\"10\" height=3D\"1\" vspace=3D\"0\" hspace=\r\n=3D\"0\" align=3D\"left\"></td> <td width=3D\"512\" height=3D\"10\"></td> <td width=\r\n=3D\"10\"><img src=3D\"http://static.naukimg.com/s/1/107//i/spacer.gif\" width=\r\n=3D\"10\" height=3D\"1\" vspace=3D\"0\" hspace=3D\"0\" align=3D\"left\"></td> </tr> <=\r\ntr> <td></td> <td style=3D\"font-family:Arial,Helvetica,sans-serif;font-size=\r\n:14px;color:#4d4d4d\"><strong>How do you rate this applicant for the positio=\r\nn?</strong></td> <td></td> </tr> <tr> <td></td> <td height=3D\"6\" style=3D\"b=\r\norder-bottom:1px #e0e0e0 solid\"></td> <td></td> </tr> <tr> <td></td> <td he=\r\night=3D\"7\"></td> <td></td> </tr> <tr> <td></td> <td valign=3D\"top\"><table b=\r\norder=3D\"0\" align=3D\"center\" cellpadding=3D\"0\" cellspacing=3D\"0\" style=3D\"m=\r\nax-width:408px;font-family:Arial,Helvetica,sans-serif;font-size:13px;color:=\r\n#303030\"> <tbody><tr> <td width=3D\"113\" height=3D\"20\">Not at all relevant</=\r\ntd> <td width=3D\"30\"><a href=3D\"http://recruit.naukri.com/rCommerce/demo/am=\r\nrScore?uid=3D5fcd1e90e7c930e6f9ea6d0be38552c063450c3e30cb63e3&amp;jid=3D270=\r\n915000532&amp;applyId=3D4753314885&amp;starRating=3D1&amp;score=3D1&amp;sou=\r\nrce=3Dn\" title=3D\"1/5\" target=3D\"_blank\"><img src=3D\"http://static.naukimg.=\r\ncom/s/1/107//i/star_3.gif\" width=3D\"16\" height=3D\"15\" vspace=3D\"0\" hspace=\r\n=3D\"7\" align=3D\"left\" style=3D\"background-color:#999999\"></a></td> <td widt=\r\nh=3D\"30\"><a href=3D\"http://recruit.naukri.com/rCommerce/demo/amrScore?uid=\r\n=3D5fcd1e90e7c930e6f9ea6d0be38552c063450c3e30cb63e3&amp;jid=3D270915000532&=\r\namp;applyId=3D4753314885&amp;starRating=3D1&amp;score=3D2&amp;source=3Dn\" t=\r\nitle=3D\"2/5\" target=3D\"_blank\"><img src=3D\"http://static.naukimg.com/s/1/10=\r\n7//i/star_3.gif\" width=3D\"16\" height=3D\"15\" vspace=3D\"0\" hspace=3D\"7\" align=\r\n=3D\"left\" style=3D\"background-color:#999999\"></a></td> <td width=3D\"30\"><a =\r\nhref=3D\"http://recruit.naukri.com/rCommerce/demo/amrScore?uid=3D5fcd1e90e7c=\r\n930e6f9ea6d0be38552c063450c3e30cb63e3&amp;jid=3D270915000532&amp;applyId=3D=\r\n4753314885&amp;starRating=3D1&amp;score=3D3&amp;source=3Dn\" title=3D\"3/5\" t=\r\narget=3D\"_blank\"><img src=3D\"http://static.naukimg.com/s/1/107//i/star_3.gi=\r\nf\" width=3D\"16\" height=3D\"15\" vspace=3D\"0\" hspace=3D\"7\" align=3D\"left\" styl=\r\ne=3D\"background-color:#999999\"></a></td> <td width=3D\"30\"><a href=3D\"http:/=\r\n/recruit.naukri.com/rCommerce/demo/amrScore?uid=3D5fcd1e90e7c930e6f9ea6d0be=\r\n38552c063450c3e30cb63e3&amp;jid=3D270915000532&amp;applyId=3D4753314885&amp=\r\n;starRating=3D1&amp;score=3D4&amp;source=3Dn\" title=3D\"4/5\" target=3D\"_blan=\r\nk\"><img src=3D\"http://static.naukimg.com/s/1/107//i/star_3.gif\" width=3D\"16=\r\n\" height=3D\"15\" vspace=3D\"0\" hspace=3D\"7\" align=3D\"left\" style=3D\"backgroun=\r\nd-color:#999999\"></a></td> <td width=3D\"42\"><a href=3D\"http://recruit.naukr=\r\ni.com/rCommerce/demo/amrScore?uid=3D5fcd1e90e7c930e6f9ea6d0be38552c063450c3=\r\ne30cb63e3&amp;jid=3D270915000532&amp;applyId=3D4753314885&amp;starRating=3D=\r\n1&amp;score=3D5&amp;source=3Dn\" title=3D\"5/5\" target=3D\"_blank\"><img src=3D=\r\n\"http://static.naukimg.com/s/1/107//i/star_3.gif\" width=3D\"16\" height=3D\"15=\r\n\" vspace=3D\"0\" hspace=3D\"7\" align=3D\"left\" style=3D\"background-color:#99999=\r\n9\"></a></td> <td width=3D\"133\">Highly Relevant</td> </tr> <tr style=3D\"font=\r\n-family:Arial,Helvetica,sans-serif;font-size:12px;color:#767676\"> <td></td>=\r\n <td align=3D\"center\"><a href=3D\"http://recruit.naukri.com/rCommerce/demo/a=\r\nmrScore?uid=3D5fcd1e90e7c930e6f9ea6d0be38552c063450c3e30cb63e3&amp;jid=3D27=\r\n0915000532&amp;applyId=3D4753314885&amp;starRating=3D1&amp;score=3D1&amp;so=\r\nurce=3Dn\" title=3D\"1/5\" style=3D\"font-family:Arial,Helvetica,sans-serif;fon=\r\nt-size:12px;color:#767676;display:block;text-decoration:none\" target=3D\"_bl=\r\nank\">1</a></td> <td align=3D\"center\"><a href=3D\"http://recruit.naukri.com/r=\r\nCommerce/demo/amrScore?uid=3D5fcd1e90e7c930e6f9ea6d0be38552c063450c3e30cb63=\r\ne3&amp;jid=3D270915000532&amp;applyId=3D4753314885&amp;starRating=3D1&amp;s=\r\ncore=3D2&amp;source=3Dn\" title=3D\"2/5\" style=3D\"font-family:Arial,Helvetica=\r\n,sans-serif;font-size:12px;color:#767676;display:block;text-decoration:none=\r\n\" target=3D\"_blank\">2</a></td> <td align=3D\"center\"><a href=3D\"http://recru=\r\nit.naukri.com/rCommerce/demo/amrScore?uid=3D5fcd1e90e7c930e6f9ea6d0be38552c=\r\n063450c3e30cb63e3&amp;jid=3D270915000532&amp;applyId=3D4753314885&amp;starR=\r\nating=3D1&amp;score=3D3&amp;source=3Dn\" title=3D\"3/5\" style=3D\"font-family:=\r\nArial,Helvetica,sans-serif;font-size:12px;color:#767676;display:block;text-=\r\ndecoration:none\" target=3D\"_blank\">3</a></td> <td align=3D\"center\"><a href=\r\n=3D\"http://recruit.naukri.com/rCommerce/demo/amrScore?uid=3D5fcd1e90e7c930e=\r\n6f9ea6d0be38552c063450c3e30cb63e3&amp;jid=3D270915000532&amp;applyId=3D4753=\r\n314885&amp;starRating=3D1&amp;score=3D4&amp;source=3Dn\" title=3D\"4/5\" style=\r\n=3D\"font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#767676;dis=\r\nplay:block;text-decoration:none\" target=3D\"_blank\">4</a></td> <td align=3D\"=\r\ncenter\"><a href=3D\"http://recruit.naukri.com/rCommerce/demo/amrScore?uid=3D=\r\n5fcd1e90e7c930e6f9ea6d0be38552c063450c3e30cb63e3&amp;jid=3D270915000532&amp=\r\n;applyId=3D4753314885&amp;starRating=3D1&amp;score=3D5&amp;source=3Dn\" titl=\r\ne=3D\"5/5\" style=3D\"font-family:Arial,Helvetica,sans-serif;font-size:12px;co=\r\nlor:#767676;display:block;text-decoration:none\" target=3D\"_blank\">5</a></td=\r\n> <td></td> </tr> </tbody></table></td> <td></td> </tr> <tr> <td height=3D\"=\r\n10\"></td> <td></td> <td></td> </tr> </tbody></table></td> </tr>  <tr> <td h=\r\neight=3D\"10\" colspan=3D\"2\"></td> </tr> <tr> <td colspan=3D\"2\">  <table widt=\r\nh=3D\"159\" border=3D\"0\" cellspacing=3D\"0\" cellpadding=3D\"0\" align=3D\"left\" s=\r\ntyle=3D\"font-family:Arial,Helvetica,sans-serif;font-size:13px;color:#0e7dcb=\r\n\"> <tbody><tr> <td width=3D\"2\"></td> <td width=3D\"139\"><a href=3D\"http://re=\r\nsponse.naukri.com/preview/show?&amp;file=3D270915000532&amp;resumeId=3D07f9=\r\n75189365da679f565f949b2bd21f59ba033e982776d6&amp;src=3Dapply\" title=3D\"View=\r\n Candidate&#39;s complete profile\" style=3D\"text-decoration:none;color:#0e7=\r\ndcb\" target=3D\"_blank\">View complete profile</a></td> <td width=3D\"18\" styl=\r\ne=3D\"border-right:1px #bdbdbd solid\"></td> </tr> <tr> <td height=3D\"8\"></td=\r\n> <td></td> <td></td> </tr> </tbody></table>   <table width=3D\"152\" border=\r\n=3D\"0\" cellspacing=3D\"0\" cellpadding=3D\"0\" align=3D\"left\" style=3D\"font-fam=\r\nily:Arial,Helvetica,sans-serif;font-size:13px;color:#0e7dcb\"> <tbody><tr> <=\r\ntd width=3D\"7\"></td> <td width=3D\"136\"><a href=3D\"http://resdex.naukri.com/=\r\nsimCV/listUserSimCV?&amp;uname=3D679d82c4d27ddee06fb103f5acf0f7e0070f500d1f=\r\n504c150717310f005808160d5a4e5e6&amp;src=3Dapply\" title=3D\"View Similar Resu=\r\nmes\" style=3D\"text-decoration:none;color:#0e7dcb\" target=3D\"_blank\">View Si=\r\nmilar Resumes</a></td> <td width=3D\"9\" style=3D\"border-right:1px #bdbdbd so=\r\nlid\"></td> </tr> <tr> <td height=3D\"8\"></td> <td></td> <td></td> </tr> </tb=\r\nody></table>  <table width=3D\"125\" border=3D\"0\" cellspacing=3D\"0\" cellpaddi=\r\nng=3D\"0\" align=3D\"left\" style=3D\"font-family:Arial,Helvetica,sans-serif;fon=\r\nt-size:13px;color:#0e7dcb\"> <tbody><tr> <td width=3D\"10\"></td> <td width=3D=\r\n\"115\"><a href=3D\"http://posting.naukri.com/paf/pafForm?amr=3D1&amp;jobId=3D=\r\n270915000532\" title=3D\"Add/ Modify Filters\" style=3D\"text-decoration:none;c=\r\nolor:#0e7dcb\" target=3D\"_blank\">Add/ Modify Filters</a></td> </tr> <tr> <td=\r\n height=3D\"8\"></td> <td></td> </tr> </tbody></table></td> </tr> <tr> <td co=\r\nlspan=3D\"2\" align=3D\"center\"><table width=3D\"100%\" border=3D\"0\" cellspacing=\r\n=3D\"0\" cellpadding=3D\"0\" align=3D\"left\" style=3D\"font-family:Arial,Helvetic=\r\na,sans-serif;font-size:13px;color:#0e7dcb\"> <tbody><tr> <td width=3D\"6\"></t=\r\nd> <td align=3D\"left\"><a href=3D\"http://www.naukri.com/tieups/tieups.php?ot=\r\nhersrcp=3D15567\" title=3D\"Get more responses through naukri\r\nReferral tool\" style=3D\"text-decoration:none;color:#0e7dcb\" target=3D\"_blan=\r\nk\">Get more responses through Naukri Referral tool</a></td> </tr> <tr> <td =\r\nheight=3D\"8\"></td> <td></td> </tr> </tbody></table></td> </tr> <tr> <td col=\r\nspan=3D\"2\" height=3D\"22\"></td> </tr> </tbody></table></td> <td width=3D\"12\"=\r\n><img src=3D\"http://static.naukimg.com/s/1/107//i/spacer.gif\" width=3D\"5\" h=\r\neight=3D\"1\" vspace=3D\"0\" hspace=3D\"0\" align=3D\"right\"></td> </tr> </tbody><=\r\n/table></td> </tr> <tr> <td height=3D\"7\"></td> </tr> </tbody></table></td> =\r\n</tr> <tr> <td colspan=3D\"2\" bgcolor=3D\"#ffffff\" valign=3D\"top\"></td> </tr>=\r\n <tr> <td height=3D\"5\"></td> <td></td> </tr> <tr> <td style=3D\"font-family:=\r\nArial,Helvetica,sans-serif;font-size:13px;color:#565656\"><strong>You can re=\r\nach us at:</strong></td> <td></td> </tr> <tr> <td height=3D\"11\"></td> <td><=\r\n/td> </tr> <tr> <td colspan=3D\"2\"><table width=3D\"116\" border=3D\"0\" cellspa=\r\ncing=3D\"0\" cellpadding=3D\"0\" align=3D\"left\" style=3D\"font-family:Arial,Helv=\r\netica,sans-serif;font-size:12px\"> <tbody><tr> <td height=3D\"3\"></td> <td></=\r\ntd> <td></td> </tr> <tr> <td width=3D\"19\"><img src=3D\"http://static.naukimg=\r\n.com/s/1/107//i/footer_icon_1.gif\" width=3D\"8\" height=3D\"8\" vspace=3D\"0\" hs=\r\npace=3D\"5\" align=3D\"left\"></td> <td width=3D\"92\"><font color=3D\"#818181\">18=\r\n00 102 5558</font></td> <td width=3D\"10\" style=3D\"border-right:1px #cdcdcd =\r\nsolid\"></td> </tr> </tbody></table> <table width=3D\"156\" border=3D\"0\" cells=\r\npacing=3D\"0\" cellpadding=3D\"0\" align=3D\"left\" style=3D\"font-family:Arial,He=\r\nlvetica,sans-serif;font-size:12px\"> <tbody><tr> <td height=3D\"3\"></td> <td>=\r\n</td> <td></td> <td></td> <td></td> </tr> <tr> <td width=3D\"11\"></td> <td w=\r\nidth=3D\"18\"><img src=3D\"http://static.naukimg.com/s/1/107//i/footer_icon_2.=\r\ngif\" width=3D\"14\" height=3D\"7\" vspace=3D\"0\" hspace=3D\"5\" align=3D\"left\"></t=\r\nd> <td width=3D\"128\"><a href=3D\"mailto:support@test.com\" title=3D\"support@n=\r\naukri.com\" style=3D\"text-decoration:none;color:#0e7dcb\" target=3D\"_blank\"><=\r\nfont color=3D\"0e7dcb\">support@test.com</font></a></td> <td width=3D\"10\" sty=\r\nle=3D\"border-right:1px #cdcdcd solid\"></td> <td width=3D\"11\"></td> </tr> </=\r\ntbody></table> <table width=3D\"108\" border=3D\"0\" cellspacing=3D\"0\" cellpadd=\r\ning=3D\"0\" align=3D\"left\" style=3D\"font-family:Arial,Helvetica,sans-serif;fo=\r\nnt-size:12px\"> <tbody><tr> <td height=3D\"3\"></td> <td></td> </tr> <tr> <td =\r\nwidth=3D\"22\"><img src=3D\"http://static.naukimg.com/s/1/107//i/footer_icon_3=\r\n.gif\" width=3D\"12\" height=3D\"11\" vspace=3D\"0\" hspace=3D\"5\" align=3D\"left\"><=\r\n/td> <td width=3D\"86\"><a href=3D\"http://www.test.com/mynaukri/mn_contactus.=\r\nphp\" title=3D\"Our Branches\" style=3D\"text-decoration:none;color:#0e7dcb\" ta=\r\nrget=3D\"_blank\"><font color=3D\"0e7dcb\">Our Branches</font></a></td> </tr> <=\r\n/tbody></table> <table width=3D\"127\" border=3D\"0\" cellspacing=3D\"0\" cellpad=\r\nding=3D\"0\" align=3D\"right\" style=3D\"font-family:Arial,Helvetica,sans-serif;=\r\nfont-size:12px\"> <tbody><tr> <td height=3D\"3\"></td> <td></td> </tr> <tr> <t=\r\nd width=3D\"24\"><img src=3D\"http://static.naukimg.com/s/1/107//i/footer_icon=\r\n_4.gif\" width=3D\"9\" height=3D\"10\" vspace=3D\"0\" hspace=3D\"5\" align=3D\"left\">=\r\n</td> <td width=3D\"103\"><a href=3D\"http://w5.test.com/fdbck/main/feedback.p=\r\nhp?app_id=3D18\" title=3D\"Report a problem\" style=3D\"text-decoration:none;co=\r\nlor:#0e7dcb\" target=3D\"_blank\"><font color=3D\"0e7dcb\">Report a problem</fon=\r\nt></a></td> </tr> </tbody></table></td> </tr> <tr> <td height=3D\"30\"></td> =\r\n<td></td> </tr> </tbody></table></td> <td width=3D\"16\"><img src=3D\"http://s=\r\ntatic.naukimg.com/s/1/107//i/spacer.gif\" width=3D\"10\" height=3D\"1\" vspace=\r\n=3D\"0\" hspace=3D\"0\" align=3D\"right\"></td> </tr> </tbody></table></td> </tr>=\r\n </tbody></table> </div> </div><br></div>\r\n

I got a lot of annoying =\r\n in my html. Of course, I can remove it using .gsub(/=\r\n/, ''), but this seems to be a bad way. Is there any simpler way to solve my issue?

johnnyshields commented 9 years ago

@asiniy I've seen this as well. IMHO since this is the response coming from Gmail, and I think it actually is coming from the raw mail sender, we shouldn't fix this within the gem. What do you think?

asiniy commented 9 years ago

I think we can use .gsub(/=\r\n/, '') for retrieved content. Anyways anyone who working with gmail should implement this method to get successful result.

johnnyshields commented 9 years ago

Actually I just see \r\n, I don't think I've see = char...

amoludage commented 9 years ago

Hello @asiniy @johnnyshields

I have tried this

email = @gmail_account.mailbox(label.name).find(:unread).first email.message.html_part.body.raw_source

The result for my unread mailbox is not nil value i.e email is not nil.

but I got error undefined method body for nil:NilClass because I got nil value as result of email.message.html_part.

Then I tried email.message.to_s then I got the result that you get, that is I see \r\n, but can't see = character in the result.

Can you tell me why the html_part gives nil result?

johnnyshields commented 9 years ago

@amoludage so firstly it seems you and I are seeing the same thing (\r\n without =)

Re: html_part, my understanding is that this is only populated are you using a [http://guides.rubyonrails.org/action_mailer_basics.html#sending-multipart-emails](multipart email) which includes an HTML component.

Please also note that the email.message class uses https://github.com/mikel/mail you may want to look there for answers.

amoludage commented 9 years ago

@johnnyshields Thanks,

I'm not using http://guides.rubyonrails.org/action_mailer_basics.html#sending-multipart-emails but I'll look into https://github.com/mikel/mail and let you know.

johnnyshields commented 9 years ago

@asiniy I'm inclined to close this issue because it looks like these chars are part of normal email format according to http://www.faqs.org/rfcs/rfc2822.html (see section 2.1, \r\n is referred to as CRLF). You'd probably want to preserve them if you are resending messages; I agree it's a pain when reading the text but it's not the job of Gmail gem to handle them. If you don't want this behavior you can filter it out in your app or monkey patch the Mail::Message class somehow.