]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
The ip() pagespec can now contain glob characters to match eg, a subnet full of spammers.
[ikiwiki.git] / IkiWiki.pm
index 52da3c112b26289298ef2a4a1faf7636ec6ff119..c497dd38f5b160af6c536dc9038bf31da585debb 100644 (file)
@@ -1433,7 +1433,7 @@ sub preprocess ($$$;$$) {
                        # consider it significant.
                        my @params;
                        while ($params =~ m{
-                               (?:([-\w]+)=)?          # 1: named parameter key?
+                               (?:([-.\w]+)=)?         # 1: named parameter key?
                                (?:
                                        """(.*?)"""     # 2: triple-quoted value
                                |
@@ -1530,7 +1530,7 @@ sub preprocess ($$$;$$) {
                        (               # 4: the parameters..
                                \s+     # Must have space if parameters present
                                (?:
-                                       (?:[-\w]+=)?            # named parameter key?
+                                       (?:[-.\w]+=)?           # named parameter key?
                                        (?:
                                                """.*?"""       # triple-quoted value
                                                |
@@ -1558,7 +1558,7 @@ sub preprocess ($$$;$$) {
                        \s+
                        (               # 4: the parameters..
                                (?:
-                                       (?:[-\w]+=)?            # named parameter key?
+                                       (?:[-.\w]+=)?           # named parameter key?
                                        (?:
                                                """.*?"""       # triple-quoted value
                                                |
@@ -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 {