]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Config.pm
doc: various overview-level module comments
[public-inbox.git] / lib / PublicInbox / Config.pm
index 369d9bda65957443c80229da717c23a58d61384f..a2b721d2a33c212f9f76dd3c0ac728f559fb7e7a 100644 (file)
@@ -1,5 +1,5 @@
-# Copyright (C) 2014-2015 all contributors <meta@public-inbox.org>
-# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
+# Copyright (C) 2014-2018 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Used throughout the project for reading configuration
 package PublicInbox::Config;
@@ -54,7 +54,7 @@ sub lookup {
        my $pfx;
 
        foreach my $k (keys %$self) {
-               $k =~ /\A(publicinbox\.[\w-]+)\.address\z/ or next;
+               $k =~ m!\A(publicinbox\.[^/]+)\.address\z! or next;
                my $v = $self->{$k};
                if (ref($v) eq "ARRAY") {
                        foreach my $alias (@$v) {
@@ -81,7 +81,7 @@ sub each_inbox {
        my ($self, $cb) = @_;
        my %seen;
        foreach my $k (keys %$self) {
-               $k =~ /\Apublicinbox\.([A-Z0-9a-z-]+)\.mainrepo\z/ or next;
+               $k =~ m!\Apublicinbox\.([^/]+)\.mainrepo\z! or next;
                next if $seen{$1};
                $seen{$1} = 1;
                my $ibx = lookup_name($self, $1) or next;
@@ -96,7 +96,7 @@ sub lookup_newsgroup {
        return $rv if $rv;
 
        foreach my $k (keys %$self) {
-               $k =~ /\A(publicinbox\.[\w-]+)\.newsgroup\z/ or next;
+               $k =~ m!\A(publicinbox\.[^/]+)\.newsgroup\z! or next;
                my $v = $self->{$k};
                my $pfx = $1;
                if ($v eq $ng) {
@@ -158,7 +158,7 @@ sub _fill {
 
        foreach my $k (qw(mainrepo filter url newsgroup
                        infourl watch watchheader httpbackendmax
-                       replyto feedmax nntpserver)) {
+                       replyto feedmax nntpserver indexlevel)) {
                my $v = $self->{"$pfx.$k"};
                $rv->{$k} = $v if defined $v;
        }
@@ -184,6 +184,13 @@ sub _fill {
        return unless $rv->{mainrepo};
        my $name = $pfx;
        $name =~ s/\Apublicinbox\.//;
+
+       # same rules as git.git/remote.c::valid_remote_nick
+       if ($name eq '' || $name =~ m!/! || $name eq '.' || $name eq '..') {
+               warn "invalid inbox name: '$name'\n";
+               return;
+       }
+
        $rv->{name} = $name;
        $rv->{-pi_config} = $self;
        $rv = PublicInbox::Inbox->new($rv);