Our Blog
Tags
Protecting your website forms and visitors from spam
Note: The anti-form-spam technique discussed here is specifically for developers who use the Ruby on Rails framework. While the concepts are still relevant, you may have to research how to implement them using the architecture and languages your website uses.
Many blogs, such as ours here at Ameravant, allow visitors to contribute to the articles by posting comments. As part of that comment, a name, email address and comment itself are usually collected. However, if a blog post receives attention from humans, it will also start getting attention from spam bots and scrapers. This puts both your website content and your visitors at risk.
Spam bots (or scrapers) are scripts or programs that discover forms and email addresses posted on websites, and automatically uses them to distribute spam. Usually, the intention of the spam is to share addresses to websites that they want to direct traffic to (usually those dealing with medications like Viagra and other sexually-related drugs). If you've used the Internet for more than a couple months, you have definitely experienced spam.
If web forms are not properly protected, these bots will cause a headache for the website owner, requiring them to periodically delete the bogus comments. Your visitors who have left comments on your blog will also be exposed to having their email address scraped and later spammed directly.
It is important to protect both yourself and your visitors from obviously-unwanted spam. There are a few good techniques for this. First, let's talk about how to still display email addresses on your site, but keep them hidden from those annoying spammers.
Camouflage your visitors' email addresses
Ruby on Rails has built-in email address encoding that is very easy to use. You can choose from two methods, either HTML or JavaScript hex encoding. The Ruby on Rails mail_to helper is all you need.
The hex encoding will output the email address entirely with HTML hex values for characters. Here is how you use it:
<%= mail_to "john_smith@mailinator.com", "Email John Smith", :encode => :hex %>
While the visitors to your site will see an actual email address and be able to copy it or click on it, this is what the source code will show:
<a href="mailto:%6a%6f%68%6e%5f%73%6d%69%74%68@%6d%61%69%6c%69%6e%61%74%6f%72.%63%6f%6d">Email John Smith</a>
The other option is to use JavaScript to output the email address, also encoded using hex values of characters. You simply change the encode option to use javascript, like so:
<%= mail_to "john_smith@mailinator.com", "Email John Smith", :encode => :javascript %>
And here is what the output looks like:
<script type="text/javascript"> eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6a%6f%68%6e%5f%73%6d%69%74%68%40%6d%61%69%6c%69%6e%61%74%6f%72%2e%63%6f%6d%22%3e%45%6d%61%69%6c%20%4a%6f%68%6e%20%53%6d%69%74%68%3c%2f%61%3e%27%29%3b')) </script>
You've now done your part to protect your visitors from spam. If they know you are helping hide their email address from potential spammers, they may be more inclined to provide their address when posting a comment.
Protecting your own site against form spam
CAPTCHAs have become a very popular way to combat spam, but so many of them have become nearly too complicated looking for me to decipher at times. The technique I have always liked to use simply uses CSS to convince the spam bot that a form field exists that actually isn't shown to a real human visitor.
The concept is very simple. You put a field in your form that you actually don't expect to be used by human visitors. For example, on our blogs we only ask for name, email address and a comment. So, our fake field could be something like "company", "website", or "city". The spam bot inspects the HTML source code of the site and blindly provides input for every field of a web form that it finds an HTML tag for. Since it will submit our fake field, which we simply hide by using the CSS display:none setting, we can reject any comments that provide data for this field.
Since bots may be improved to look for a "style" attribute in your HTML input tags, you should put the CSS display:none setting inside an externally-included CSS file, as opposed to directly in the source code of the page that the form is on.
Following these two techniques is a great start to fighting against spam, protecting both yourself and your visitors from some headaches.
Find related posts: ruby on rails spam tutorial
Comments
<a href="http://www.baidu.com">baidu</a>
I'll have to think twice before I comment on a persons blog, or an article.
http://www.thebridalbell.com"
I think this is great
[url=http://www.christianlouboutinsize.com/]Christian Louboutin[/url] and set off the beautiful qualities of [url=http://www.x-jewelrybox.com/]Pandora Jewelry[/url], you have a heart for any man's temperament. And then combined with the [url=http://www.undvdsales.com/insanity-workout-dvd-c-50.html]Insanity DVD[/url] fitness program, put [url=http://www.dvdsales-x.com/vibram-five-fingers-c-19.html]Vibram Five Fingers[/url] and [url=http://www.nfljerseysnba.com/]NFL Jerseys[/url], so that men are envious of your vitality.[url=http://www.christianlouboutinsize.com/christian-louboutin-knockoffs-shoes-p-373.html]Christian Louboutin Knockoffs[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-wedding-shoes-p-316.html]Christian Louboutin Wedding Shoes[/url],
[url=http://www.christianlouboutinsize.com/christian-louboutin-boots-c-30.html]Christian Louboutin Boots[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-sandals-c-32.html]Christian Louboutin Sandals[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-wedges-c-34.html]Christian Louboutin Wedges[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-platform-c-91.html]Christian Louboutin Platform[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-sneakers-c-92.html]Christian Louboutin Sneakers[/url][url=http://www.christianlouboutinsize.com/christian-louboutin-nappa-bootie-red-p-236.html]Christian Louboutin Nappa Bootie[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-suede-ankle-boots-gray-p-203.html]Christian Louboutin Ankle Boots[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-miss-clichy-boots-p-233.html]Christian Louboutin Leopard Boots[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-leopard-print-shoes-p-396.html]christian louboutin leopard[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-bianca-140-python-pumps-p-421.html]christian louboutin python pumps[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-pumps-c-31.html]christian louboutin black pumps[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-black-leather-patent-pigalle-pumps-p-159.html]christian louboutin platform pump[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-black-satin-peep-toe-pumps-p-318.html]Christian Louboutin Peep Toe[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-declic-pumps-pink-p-495.html]Christian Louboutin Declic Pumps[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-very-prive-pumps-lambskin-pink-p-317.html]christian louboutin very prive pumps[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-slingback-c-33.html]Christian Louboutin Slingbacks[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-cathay-peep-toe-slingbacks-p-1208.html]Christian Louboutin Cathay[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-platform-pump-black-paten-p-395.html]Christian Louboutin High Heels[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-pigalle-pumps-nude-leather-multi-color-p-269.html]Christian Louboutin Pigalle[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-mad-mary-janes-three-strap-white-p-286.html]Christian Louboutin Mary Janes[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-wedding-shoes-p-316.html]Christian Louboutin Wedding Shoes[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-declic-pumps-black-p-499.html]Christian Louboutin Declic Leather Pumps[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-platform-lace-up-bootie-black-p-210.html]Christian Louboutin Lace Up Boots[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-robot-ankle-boots-p-220.html]Christian Louboutin Robot[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-peep-toe-boots-p-221.html]Christian Louboutin Peep Toe Boots[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-over-the-knee-suede-boots-p-264.html]Christian Louboutin over the knee boots[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-babel-leather-boots-p-257.html]christian louboutin babel boots[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-nitoinimoi-suede-boots-p-199.html]Christian Louboutin Bandage Boots[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-bouquet-platform-p-1371.html]Christian Louboutin Bouquet Platform[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-dillian-pumps-p-1434.html]Christian Louboutin Dillian Pumps[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-macarena-wedge-sandals-p-454.html]christian louboutin macarena[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-rolando-hidden-platform-pump-black-p-289.html]red sole shoes[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-candy-studded-flats-black-p-1373.html]Christian Louboutin Flats[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-double-platform-sandals-white-p-1798.html]Christian Louboutin Double Platform Sandal[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-carnaval-black-p-193.html]Christian Louboutin Evening[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-calypso-pumps-p-400.html]christian louboutin calypso pumps[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-d-orsay-pumps-p-324.html]christian louboutin d'orsay[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-alta-nodo-dorsay-pewter-metallic-p-327.html]Christian Louboutin Alta Nodo[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-petal-sandal-black-p-358.html]christian louboutin petal pumps[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-black-petal-crepe-satin-sandal-p-356.html]christian louboutin petal crepe satin sandal[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-knockoffs-shoes-p-373.html]replica christian louboutin shoes[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-rolando-hidden-platform-pumps-p-440.html]Christian Louboutin Platform Pumps[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-wedge-espadrille-black-p-1210.html]Christian Louboutin Espadrille Wedge[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-jeweled-platform-slingback-pink-p-309.html]Christian Louboutin Jeweled Pumps[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-cutout-peeptoe-pump-p-325.html]christian louboutin cutout pump[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-cutout-bootie-p-361.html]Christian Louboutin Cutout Bootie[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-glittered-platform-pump-oxblood-p-341.html]christian louboutin glitter pump[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-circus-cutout-suede-ankle-boots-p-214.html]christian louboutin circus boots[/url],[url=http://www.christianlouboutinsize.com/christian-louboutin-sample-black-p-1772.html]christian louboutin sample sale[/url],ED Hardy [url=http://www.edhardy2005.com/]ED Hardy[/url],Nike Shoes [url=http://www.airdunksb.com/]Nike Shoes[/url],Abercrombie and Fitch [url=http://www.saleabercrombie.com/]Abercrombie and Fitch[/url],Gift Ideas [url=http://www.giftideas-x.com/]Gift Ideas[/url],Tiffany Jewelry [url=http://www.x-tiffanyjewelry.com/]Tiffany Jewelry[/url],Ball Bearing [url=http://www.x-bearing.com/]Ball Bearing[/url],Christian Louboutin [url=http://www.louboutin-x.com/]Christian Louboutin Discount[/url],UGG Boots [url=http://www.x-uggboots.com/]UGG Boots[/url],EMU Boots [url=http://www.emubootscheap.com/]EMU Boots[/url],Louis Vuitton Handbags [url=http://www.handbagses.com/]Louis Vuitton Handbags[/url],Christian Audigier [url=http://www.edhardy-x.com/]Christian Audigier[/url]