diff options
author | Joey Hess <joey@kitenet.net> | 2013-07-08 11:49:38 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-07-08 11:49:38 -0400 |
commit | 533793ee462552dd0b782a69e2cfe48c8f93dedc (patch) | |
tree | 2502390f3fe2d30d227a990ac098d0195ff2dc24 | |
parent | 9eea60f0cbd2a25f06adae1636d41a4936c3e8a2 (diff) | |
download | ikiwiki-533793ee462552dd0b782a69e2cfe48c8f93dedc.tar ikiwiki-533793ee462552dd0b782a69e2cfe48c8f93dedc.tar.gz |
The ip() pagespec can now contain glob characters to match eg, a subnet full of spammers.
-rw-r--r-- | IkiWiki.pm | 8 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/ikiwiki/pagespec.mdwn | 3 |
3 files changed, 9 insertions, 4 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index 0570c8bc5..c497dd38f 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -2776,12 +2776,12 @@ sub match_user ($$;@) { my $user=shift; my %params=@_; - my $regexp=IkiWiki::glob2re($user); - 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"); } @@ -2821,8 +2821,10 @@ sub match_ip ($$;@) { 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 { diff --git a/debian/changelog b/debian/changelog index 587a375b9..04feaffcb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,8 @@ ikiwiki (3.20130519) UNRELEASED; urgency=low (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 diff --git a/doc/ikiwiki/pagespec.mdwn b/doc/ikiwiki/pagespec.mdwn index fe1af4c15..0f298ad78 100644 --- a/doc/ikiwiki/pagespec.mdwn +++ b/doc/ikiwiki/pagespec.mdwn @@ -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 - 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 |