The ip() pagespec can now contain glob characters to match eg, a subnet full of spammers.

master
Joey Hess 2013-07-08 11:49:38 -04:00
parent 9eea60f0cb
commit 533793ee46
3 changed files with 9 additions and 4 deletions

View File

@ -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 {

2
debian/changelog vendored
View File

@ -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

View 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
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