Page 1 of 1

Bug in spamblock module with htaccess

Posted: Tue Feb 24, 2009 12:47 am
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)

Re: Bug in spamblock module with htaccess

Posted: Tue Feb 24, 2009 9:31 am
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