]> Sergey Matveev's repositories - public-inbox.git/commitdiff
require ASCII digits for local FS items
authorEric Wong <e@80x24.org>
Tue, 4 Jun 2019 08:40:34 +0000 (08:40 +0000)
committerEric Wong <e@80x24.org>
Tue, 4 Jun 2019 10:06:18 +0000 (10:06 +0000)
In case some BOFH decides to randomly create directories
using non-ASCII digits all over the place.

lib/PublicInbox/Inbox.pm
lib/PublicInbox/Search.pm
lib/PublicInbox/V2Writable.pm
lib/PublicInbox/Xapcmd.pm
script/public-inbox-purge

index 04d2f83209851989f402b7161da3b7bb494b2e53..c93303322194e024b8125b8d8b64ca014fe00483 100644 (file)
@@ -87,7 +87,7 @@ sub _set_limiter ($$$) {
                my $mkey = $pfx.'max';
                my $val = $self->{$mkey} or return;
                my $lim;
-               if ($val =~ /\A\d+\z/) {
+               if ($val =~ /\A[0-9]+\z/) {
                        require PublicInbox::Qspawn;
                        $lim = PublicInbox::Qspawn::Limiter->new($val);
                } elsif ($val =~ /\A[a-z][a-z0-9]*\z/) {
@@ -161,7 +161,7 @@ sub max_git_part {
                if (opendir my $dh, $gits) {
                        my $max = -1;
                        while (defined(my $git_dir = readdir($dh))) {
-                               $git_dir =~ m!\A(\d+)\.git\z! or next;
+                               $git_dir =~ m!\A([0-9]+)\.git\z! or next;
                                $max = $1 if $1 > $max;
                        }
                        $part = $self->{-max_git_part} = $max if $max >= 0;
index c054a87497c400f3a2b2053b94f828eff78400d0..9903f427013bebeee9bbd1f427965a8c6cd84ede 100644 (file)
@@ -144,7 +144,7 @@ sub _xdb ($) {
        my $qpf = \($self->{qp_flags} ||= $QP_FLAGS);
        if ($self->{version} >= 2) {
                foreach my $part (<$dir/*>) {
-                       -d $part && $part =~ m!/\d+\z! or next;
+                       -d $part && $part =~ m!/[0-9]+\z! or next;
                        my $sub = Search::Xapian::Database->new($part);
                        if ($xdb) {
                                $xdb->add_database($sub);
index 76844cd45a0f046b91a35263e9de046899f37f77..a8c33ef4f8f1d09848e6e12f3a9b625a0d1baa85 100644 (file)
@@ -48,7 +48,7 @@ sub count_partitions ($) {
        # due to -compact
        if (-d $xpfx) {
                foreach my $part (<$xpfx/*>) {
-                       -d $part && $part =~ m!/\d+\z! or next;
+                       -d $part && $part =~ m!/[0-9]+\z! or next;
                        eval {
                                Search::Xapian::Database->new($part)->close;
                                $nparts++;
@@ -574,7 +574,7 @@ sub git_dir_latest {
        my $latest;
        opendir my $dh, $pfx or die "opendir $pfx: $!\n";
        while (defined(my $git_dir = readdir($dh))) {
-               $git_dir =~ m!\A(\d+)\.git\z! or next;
+               $git_dir =~ m!\A([0-9]+)\.git\z! or next;
                if ($1 > $$max) {
                        $$max = $1;
                        $latest = "$pfx/$git_dir";
index 906723104d553d2cb25465c4dfd488e213914a0f..dad080c83bd724ff4998cfd459465a58b2b0b2f3 100644 (file)
@@ -150,7 +150,7 @@ sub run {
        } else {
                opendir my $dh, $old or die "Failed to opendir $old: $!\n";
                while (defined(my $dn = readdir($dh))) {
-                       if ($dn =~ /\A\d+\z/) {
+                       if ($dn =~ /\A[0-9]+\z/) {
                                my $tmpl = "$dn-XXXXXXXX";
                                my $dst = tempdir($tmpl, DIR => $old);
                                same_fs_or_die($old, $dst);
@@ -200,7 +200,7 @@ sub progress_pfx ($) {
        my @p = split('/', $_[0]);
 
        # return "xap15/0" for v2, or "xapian15" for v1:
-       ($p[-1] =~ /\A\d+\z/) ? "$p[-2]/$p[-1]" : $p[-1];
+       ($p[-1] =~ /\A[0-9]+\z/) ? "$p[-2]/$p[-1]" : $p[-1];
 }
 
 # xapian-compact wrapper
@@ -276,7 +276,7 @@ sub cpdb ($$) {
                        $dst->set_metadata('last_commit', $lc) if $lc;
 
                        # only the first xapian partition (0) gets 'indexlevel'
-                       if ($old =~ m!(?:xapian\d+|xap\d+/0)\z!) {
+                       if ($old =~ m!(?:xapian[0-9]+|xap[0-9]+/0)\z!) {
                                my $l = $src->get_metadata('indexlevel');
                                if ($l eq 'medium') {
                                        $dst->set_metadata('indexlevel', $l);
index 381826dc440c8ca43546aa823dd0b4aab93e39c2..25e6cc9b782451a5774acde97d7454d70f8d5a3e 100755 (executable)
@@ -91,7 +91,7 @@ foreach my $ibx (@inboxes) {
        my $xdir_ro = $ibx->{search}->xdir(1);
        my $npart = 0;
        foreach my $part (<$xdir_ro/*>) {
-               if (-d $part && $part =~ m!/\d+\z!) {
+               if (-d $part && $part =~ m!/[0-9]+\z!) {
                        my $bytes = 0;
                        $bytes += -s $_ foreach glob("$part/*");
                        $npart++ if $bytes;