Patch to add rel="nofollow" to captchas

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Zugschlus
Regular
Posts: 144
Joined: Sun Feb 05, 2006 12:54 am
Location: St. Ilgen, Germany
Contact:

Patch to add rel="nofollow" to captchas

Post 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)
                                     );
--
Marc Haber, St. Ilgen, Germany
https://blog.zugschlus.de/ - nach langer Pause jetzt wieder online
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

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

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Zugschlus
Regular
Posts: 144
Joined: Sun Feb 05, 2006 12:54 am
Location: St. Ilgen, Germany
Contact:

Post 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?
--
Marc Haber, St. Ilgen, Germany
https://blog.zugschlus.de/ - nach langer Pause jetzt wieder online
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply