Henry Lyne (henrylyne) wrote in changelog,
Henry Lyne
henrylyne
changelog

[livejournal] r15626: Allow sysbans to work even when BLOCKED_...

Committer: henrylyne
Allow sysbans to work even when BLOCKED_BOT_URI is not defined.

Thanks to DW for patch:
http://bugs.dwscoalition.org/show_bug.cgi?id=1285

U   trunk/cgi-bin/Apache/LiveJournal.pm
U   trunk/cgi-bin/LJ/UniqCookie.pm
Modified: trunk/cgi-bin/Apache/LiveJournal.pm
===================================================================
--- trunk/cgi-bin/Apache/LiveJournal.pm	2009-08-21 16:55:42 UTC (rev 15625)
+++ trunk/cgi-bin/Apache/LiveJournal.pm	2009-08-21 17:15:36 UTC (rev 15626)
@@ -348,18 +348,21 @@
     }
 
     # check for sysbans on ip address
-    foreach my $ip (@req_hosts) {
-        if (LJ::sysban_check('ip', $ip) && index($uri, $LJ::BLOCKED_BOT_URI) != 0) {
+    # Don't block requests against the bot URI, if defined
+    unless ( $LJ::BLOCKED_BOT_URI && index( $uri, $LJ::BLOCKED_BOT_URI ) == 0 ) {
+        foreach my $ip (@req_hosts) {
+            if (LJ::sysban_check('ip', $ip)) {
+                $r->handler("perl-script");
+                $r->push_handlers(PerlHandler => \&blocked_bot );
+                return OK;
+            }
+        }
+        if (LJ::run_hook("forbid_request", $r)) {
             $r->handler("perl-script");
             $r->push_handlers(PerlHandler => \&blocked_bot );
             return OK;
         }
     }
-    if (LJ::run_hook("forbid_request", $r) && index($uri, $LJ::BLOCKED_BOT_URI) != 0) {
-        $r->handler("perl-script");
-        $r->push_handlers(PerlHandler => \&blocked_bot );
-        return OK;
-    }
 
     # see if we should setup a minimal scheme based on the initial part of the
     # user-agent string; FIXME: maybe this should do more than just look at the

Modified: trunk/cgi-bin/LJ/UniqCookie.pm
===================================================================
--- trunk/cgi-bin/LJ/UniqCookie.pm	2009-08-21 16:55:42 UTC (rev 15625)
+++ trunk/cgi-bin/LJ/UniqCookie.pm	2009-08-21 17:15:36 UTC (rev 15626)
@@ -440,13 +440,12 @@
 
     my $r = Apache->request;
     my $uri = $r->uri;
+    return 0 if ( $LJ::BLOCKED_BOT_URI && index( $uri, $LJ::BLOCKED_BOT_URI ) == 0 );
 
     # if cookie exists, check for sysban
     if (my @cookieparts = $class->parts_from_cookie) {
         my ($uniq, $uniq_time, $uniq_extra) = @cookieparts;
-        if (LJ::sysban_check('uniq', $uniq) && index($uri, $LJ::BLOCKED_BOT_URI) != 0) {
-            return 1;
-        }
+        return 1 if LJ::sysban_check( 'uniq', $uniq );
     }
 
     return 0;

Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments