Some users on social sites still enter their email addresses on comment fields. I'm trying to prevent spammers from harvesting them by replacing the @ character with a graphic. That's really easy to do using the smiley module.

However, I use the text filter option "Convert URLs into links" which turns the email into a mailto link. The smiley filter now breaks the HTML.

I would like to not turn emails into links but keep turning urls into links. How could I do that?


The easiest way is to creat your own input filter. Do a PREG and obfuscate the email address. Assign this filter to your input formats, and make sure it runs before the URL-to-link one.

| improve this answer | |
  • thanks. I don't think I could obfuscate it with a graphic if it gets turned into a link afterwards. I could replace @ with @ but but that could be hacked easily – uwe Feb 19 '13 at 6:38
  • Definitely, a custom input filter is by far the easiest solution – Clive Feb 19 '13 at 9:39
  • @MotoTribe If you obfuscate it before the URL-to-link filter runs, then it shouldn't get turned into a link. Look at the code for _filter_url. If the "@" isn't there, then it' won't match. – mpdonadio Feb 19 '13 at 12:09

Spamfree email module replaces email address with mailto links and obfuscates to js code for js supporting browsers and to image for non js browser thus preventing email harvest bots.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.