Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting [email protected] when trying to display eamil using collection_select

I am using Ruby 1.8.7 with Rails 2.3.9. When creating a drop down of email addresses using collection select, the emails addresses are not displaying. Instead I am seeing "[email protected]" in the drop down. Is there some switch that is causing this?

There seems to be some javascript that is being applied to each item in the drop down by rails when it sees an email in the list. The javascript is not there when I just list the user names.

<script type="text/javascript">
/* <![CDATA[ */
3(function(){try{var s,a,i,j,r,c,l=document.getElementById("__cf_email__");a=l.getAttribute("cf_sec");if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
4/* ]]> */ 
<script/>
like image 412
Nicolo77 Avatar asked Oct 11 '10 22:10

Nicolo77


2 Answers

Hoa you are correct this isn't rails related.

I found that this caused by the CDN we are using CloudFlare. As part of their security settings they obscure emails.

You can turn this off by going to the CloudFlare settings on your CloudFlare account and turn off E-mail Address Obfuscation.

Update: This is definitely a CloudFlare setting that prevents emails from being displayed (saw this happen in my active_admin), but know that you can also add some HTML to the output that CloudFlare will look for around the email output:

<!--email_off--> [email protected] <!--/email_off-->

Reference:

  • What is email address obfuscation?
like image 133
Nicolo77 Avatar answered Oct 14 '22 18:10

Nicolo77


Adding to @Nicolo77 answer.

I have ran into same issue. Cloud flare by default Turn on Email Address Obfuscation. You can change it on your could flare dashboard:

Login->Scrape Shield->Email Address Obfuscation -> Turn Off

like image 4
Dheeraj Palagiri Avatar answered Oct 14 '22 18:10

Dheeraj Palagiri