Preventing comment spam

A new standard HTML tag supported by Google and other search engines will help eliminate the incentive to post comment spam. When the attribute rel=”nofollow” is added to a link, that site won’t be credited for the link and its search engine ranking won’t be raised. Ideally, blogging software should automatically append it to any user-provided links.

I’ve implemented it in Drupal with a simple patch to filter.module. Add the following line near the end of the function _filter_html, just before the line return trim($text);


$text = preg_replace('|<a.+href=([^>]*)>|','<a href=$1 rel="nofollow">',$text);

Both MacMegasite & WorldBeatPlanet are running that patch now.

Comments are closed.