This won't actually prevent spam from being posted, but it will eliminate any incentive to spam. Google announced a new attribute which will prevent a link from raising a site's ranking. If all user-posted links have 'rel=nofollow' added, posting a comment on your site will have no effect on the poster's site. A simple patch to filter.module will automatically append it to any link in a user's post.

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);

I've implemented this patch at both macmegasite & worldbeatplanet.

Comments

kevin@gotdoof.com’s picture

Won't this affect nodes posted using the standard html filter? Is there any way to do this to comments only?

mike3k’s picture

Yes, it does affect nodes. I'm not sure if it's possible to limit it to comments only. However, if you use full HTML instead of filtered HTML the links will be unchanged. If you limit full HTML to only registered users or add another role to allow it, anonymous users are forced to use the filter.

--
Mike Cohen, http://www.mcdevzone.com/