Bug in spamblock module with htaccess

Found a bug? Tell us!!
Post Reply
brielle
Posts: 1
Joined: Tue Feb 24, 2009 12:39 am

Bug in spamblock module with htaccess

Post by brielle »

Hello All,

I've found a slight bug in how the Deny rules in .htaccess by the spamblock module are created.

Seems that (at least on my system), a Deny rule should be space separated list of IPs, not comma separated. This makes the htaccess deny list not actually block.

I've attached a patch to the 1.72 version of the spamblock module. Hope this helps!

Code: Select all

--- serendipity_event_spamblock.php.orig        2009-02-23 16:36:13.000000000 -0700
+++ serendipity_event_spamblock.php     2009-02-23 16:33:21.000000000 -0700
@@ -439,9 +439,9 @@
                 // Check if an old htaccess file existed and try to preserve its contents. Otherwise completely wipe the file.
                 if ($htaccess != '' && preg_match('@^(.*)#SPAMDENY.*Deny From.+#/SPAMDENY(.*)$@imsU', $htaccess, $match)) {
                     // Code outside from s9y-code was found.
-                    $content = trim($match[1]) . "\n#SPAMDENY\nDeny From " . implode(',', $deny) . "\n#/SPAMDENY\n" . trim($match[2]);
+                    $content = trim($match[1]) . "\n#SPAMDENY\nDeny From " . implode(' ', $deny) . "\n#/SPAMDENY\n" . trim($match[2]);
                 } else {
-                    $content = trim($htaccess) . "\n#SPAMDENY\nDeny From " . implode(',', $deny) . "\n#/SPAMDENY\n";
+                    $content = trim($htaccess) . "\n#SPAMDENY\nDeny From " . implode(' ', $deny) . "\n#/SPAMDENY\n";
                 }
                 fwrite($fp, $content);
                 fclose($fp)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Bug in spamblock module with htaccess

Post by garvinhicking »

Hi!

You're right, it seems some versions of apache can take the comma, while others cannot. But "space" always work, so I've committed your patch!

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