]> Sergey Matveev's repositories - public-inbox.git/commitdiff
altid: warn about non-word prefixes
authorEric Wong <e@yhbt.net>
Sat, 21 Mar 2020 02:03:53 +0000 (02:03 +0000)
committerEric Wong <e@yhbt.net>
Wed, 25 Mar 2020 01:48:35 +0000 (01:48 +0000)
We only support searching on prefixes matching /\A\w+\z/ because
Xapian requires ':' to delimit the prefix and splits on spaces
without quotes.

I've also verified Xapian supports multibyte UTF-8 characters,
underscores, and bare numbers as search prefixes, so there's
no need to restrict it beyond what Perl's UTF-8 aware \w
character class offers.

lib/PublicInbox/AltId.pm
lib/PublicInbox/Search.pm

index 8ce70e46042f0b7e1c38e2fe191ae2a58eb548a7..3be6c73cc0e93c52220e554543bc640e7123f1a8 100644 (file)
@@ -22,7 +22,7 @@ sub new {
        my ($class, $ibx, $spec, $writable) = @_;
        my ($type, $prefix, $query) = split(/:/, $spec, 3);
        $type eq 'serial' or die "non-serial not supported, yet\n";
-
+       $prefix =~ /\A\w+\z/ or warn "non-word prefix not searchable\n";
        my %params = map {
                my ($k, $v) = split(/=/, uri_unescape($_), 2);
                $v = '' unless defined $v;
index fabf5301f163187035c2cdd1a51895e98ba8116a..86a6ad674b3e1fbfdb70d3a04d8dac40d4fae881 100644 (file)
@@ -316,6 +316,8 @@ sub qp {
                my $user_pfx = $self->{-user_pfx} = [];
                for (@$altid) {
                        # $_ = 'serial:gmane:/path/to/gmane.msgmap.sqlite3'
+                       # note: Xapian supports multibyte UTF-8, /^[0-9]+$/,
+                       # and '_' with prefixes matching \w+
                        /\Aserial:(\w+):/ or next;
                        my $pfx = $1;
                        push @$user_pfx, "$pfx:", <<EOF;