Page 1 of 1

Patch to add rel="nofollow" to captchas

Posted: Wed Sep 06, 2006 12:42 pm
by Zugschlus
Hi,

Google Images is indexing s9y captchas by truckload. I'd like to suggest the following patch to keep Google from indexing these:

Code: Select all

--- serendipity_event_spamblock.php.orig        2006-09-06 12:38:15.000000000 +0200
+++ serendipity_event_spamblock.php     2006-09-06 12:39:20.000000000 +0200
@@ -859,7 +859,7 @@
                         if (!isset($serendipity['POST']['preview']) || strtolower($serendipity['POST']['captcha'] != strtolower($_SESSION['spamblock']['captcha']))) {
                             echo '<br />' . PLUGIN_EVENT_SPAMBLOCK_CAPTCHAS_USERDESC . '<br />';
                             if ($use_gd) {
-                                printf('<img src="%s" title="%s" alt="CAPTCHA" class="captcha" />',
+                                printf('<img src="%s" title="%s" alt="CAPTCHA" class="captcha" rel="nofollow" />',
                                     $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/captcha_' . md5(time()),
                                     htmlspecialchars(PLUGIN_EVENT_SPAMBLOCK_CAPTCHAS_USERDESC2)
                                 );
@@ -869,7 +869,7 @@
                                 $this->random_string($max_char, $min_char);
                                 echo '<div style="background-color: ' . $hexval . '">';
                                 for ($i = 1; $i <= $max_char; $i++) {
-                                    printf('<img src="%s" title="%s" alt="CAPTCHA ' . $i . '" class="captcha" />',
+                                    printf('<img src="%s" title="%s" alt="CAPTCHA ' . $i . '" class="captcha" rel="nofollow" />',
                                         $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/captcha_' . $i . '_' . md5(time()),
                                         htmlspecialchars(PLUGIN_EVENT_SPAMBLOCK_CAPTCHAS_USERDESC2)
                                     );

Re: Patch to add rel="nofollow" to captchas

Posted: Wed Sep 06, 2006 1:32 pm
by garvinhicking
Hi!

I think we had this once, by your suggestion. It showed that 'rel=nofollow' is invalid XHTML markup for the <img> tag, we can't keep it!

BerliOS SVN view is down, else I could show you the diffs where we patched it in, and where we reverted it again :)

So, you should forbid indexing via robots.txt or complain at google. :)

Best regards,
Garvin

Posted: Wed Sep 06, 2006 1:51 pm
by Zugschlus
Ah, ok. I was only very surprised to see the rel="nofollow" gone again. A pity it had to be removed.

Can you please document the pattern for the captcha URLs so that a robots.txt file can be tightly specified?

Posted: Wed Sep 06, 2006 2:04 pm
by garvinhicking
Hi!

Sure, the URL is:

with rewriting:
http://blog/plugin/captcha_XXXX

without:
http://blog/index.php?/plugin/captcha_XXX

Where as "XXX" corresponds to a random 32-digit string.

Best regards,
Garvin