]> sipb.mit.edu Git - ikiwiki.git/commitdiff
The ip() pagespec can now contain glob characters to match eg, a subnet full of spammers.
authorJoey Hess <joey@kitenet.net>
Mon, 8 Jul 2013 15:49:38 +0000 (11:49 -0400)
committerJoey Hess <joey@kitenet.net>
Mon, 8 Jul 2013 15:49:38 +0000 (11:49 -0400)
IkiWiki.pm
debian/changelog
doc/ikiwiki/pagespec.mdwn

index 0570c8bc521c3989d1c733cfb1b16fedd6770ca7..c497dd38f5b160af6c536dc9038bf31da585debb 100644 (file)
@@ -2776,12 +2776,12 @@ sub match_user ($$;@) {
        my $user=shift;
        my %params=@_;
        
        my $user=shift;
        my %params=@_;
        
-       my $regexp=IkiWiki::glob2re($user);
-       
        if (! exists $params{user}) {
                return IkiWiki::ErrorReason->new("no user specified");
        }
 
        if (! exists $params{user}) {
                return IkiWiki::ErrorReason->new("no user specified");
        }
 
+       my $regexp=IkiWiki::glob2re($user);
+       
        if (defined $params{user} && $params{user}=~$regexp) {
                return IkiWiki::SuccessReason->new("user is $user");
        }
        if (defined $params{user} && $params{user}=~$regexp) {
                return IkiWiki::SuccessReason->new("user is $user");
        }
@@ -2821,8 +2821,10 @@ sub match_ip ($$;@) {
        if (! exists $params{ip}) {
                return IkiWiki::ErrorReason->new("no IP specified");
        }
        if (! exists $params{ip}) {
                return IkiWiki::ErrorReason->new("no IP specified");
        }
+       
+       my $regexp=IkiWiki::glob2re(lc $ip);
 
 
-       if (defined $params{ip} && lc $params{ip} eq lc $ip) {
+       if (defined $params{ip} && lc $params{ip}=~$regexp) {
                return IkiWiki::SuccessReason->new("IP is $ip");
        }
        else {
                return IkiWiki::SuccessReason->new("IP is $ip");
        }
        else {
index 587a375b9b909fea1f82ef46410cd9335d41fb4d..04feaffcb5258e0f5e41d1f681092cfddd1b948a 100644 (file)
@@ -13,6 +13,8 @@ ikiwiki (3.20130519) UNRELEASED; urgency=low
     (smcv)
   * openid: Automatically upgrade openid_realm to https when
     accessed via https.
     (smcv)
   * openid: Automatically upgrade openid_realm to https when
     accessed via https.
+  * The ip() pagespec can now contain glob characters to match eg, a subnet
+    full of spammers.
 
  -- Joey Hess <joeyh@debian.org>  Sun, 23 Jun 2013 14:02:01 -0400
 
 
  -- Joey Hess <joeyh@debian.org>  Sun, 23 Jun 2013 14:02:01 -0400
 
index fe1af4c153404c35aa21232c7d0f68ddfad55f6b..0f298ad78702b5bba16d98d6585096194cfd90a4 100644 (file)
@@ -51,7 +51,8 @@ Some more elaborate limits can be added to what matches using these functions:
 * "`admin()`" - tests whether a modification is being made by one of the
   wiki admins.
 * "`ip(address)`" - tests whether a modification is being made from the
 * "`admin()`" - tests whether a modification is being made by one of the
   wiki admins.
 * "`ip(address)`" - tests whether a modification is being made from the
-  specified IP address.
+  specified IP address. Glob patterns can be used in the address. For
+  example, `ip(127.0.0.*)`
 * "`comment(glob)`" - matches comments to a page matching the glob.
 * "`comment_pending(glob)`" - matches unmoderated, pending comments.
 * "`postcomment(glob)`" - matches only when comments are being 
 * "`comment(glob)`" - matches comments to a page matching the glob.
 * "`comment_pending(glob)`" - matches unmoderated, pending comments.
 * "`postcomment(glob)`" - matches only when comments are being