my $user=shift;
my %params=@_;
+ my $regexp=IkiWiki::glob2re($user);
+
if (! exists $params{user}) {
return IkiWiki::ErrorReason->new("no user specified");
}
- if (defined $params{user} && lc $params{user} eq lc $user) {
+ if (defined $params{user} && $params{user}=~/^$regexp$/i) {
return IkiWiki::SuccessReason->new("user is $user");
}
elsif (! defined $params{user}) {
a button on the login form to use it.
* httpauth: Add httpauth_pagespec setting that can be used to limit
pages to only being edited via users authed with httpauth.
+ * Allow globs to be used in user() pagespecs.
-- Joey Hess <joeyh@debian.org> Tue, 26 Jan 2010 22:25:33 -0500
metadata, matching the specified glob.
* "`user(username)`" - tests whether a modification is being made by a
user with the specified username. If openid is enabled, an openid can also
- be put here.
+ be put here. Glob patterns can be used in the username. For example,
+ to match all openid users, use `user(*://.*)`
* "`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
#!/usr/bin/perl
use warnings;
use strict;
-use Test::More tests => 64;
+use Test::More tests => 70;
BEGIN { use_ok("IkiWiki"); }
ok(pagespec_match("{f}oo", "{*}*"), "curly match");
ok(! pagespec_match("foo", "{*}*"), "curly !match");
+ok(pagespec_match("somepage", "user(frodo)", user => "frodo"));
+ok(pagespec_match("somepage", "user(frodo)", user => "Frodo"));
+ok(! pagespec_match("somepage", "user(frodo)", user => "Sam"));
+ok(pagespec_match("somepage", "user(*o)", user => "Bilbo"));
+ok(pagespec_match("somepage", "user(*o)", user => "frodo"));
+ok(! pagespec_match("somepage", "user(*o)", user => "Sam"));
+
# The link and backlink stuff needs this.
$config{userdir}="";
$links{foo}=[qw{bar baz}];