about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-03-21 02:03:53 +0000
committerEric Wong <e@yhbt.net>2020-03-25 01:48:35 +0000
commit7909c5f7439777e3b3643f14224b27f0a8f8fb07 (patch)
tree12e9187b2069d63582c3c72546f7f71756d2f79a /lib
parent089380f8ebecbe868c5599773b3c23d40b3db129 (diff)
downloadpublic-inbox-7909c5f7439777e3b3643f14224b27f0a8f8fb07.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/AltId.pm2
-rw-r--r--lib/PublicInbox/Search.pm2
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/PublicInbox/AltId.pm b/lib/PublicInbox/AltId.pm
index 8ce70e46..3be6c73c 100644
--- a/lib/PublicInbox/AltId.pm
+++ b/lib/PublicInbox/AltId.pm
@@ -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;
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index fabf5301..86a6ad67 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -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;