From 2d5e54cc2e4bae1c370c70cc50e40ef21e82b59c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 30 Jan 2019 10:33:55 +0000 Subject: solvergit: don't confuse Xapian with ".." in filenames Xapian will interpret ".." as ranges, even quoted phrases. So break up words on ".." since punctuation (AFAIK) is not searchable, anyways. --- lib/PublicInbox/SolverGit.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index 59d2c93c..c5025269 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -170,6 +170,13 @@ sub extract_diff ($$$$$) { sub path_searchable ($) { defined($_[0]) && $_[0] =~ m!\A[\w/\. \-]+\z! } +# ".." appears in path names, which confuses Xapian into treating +# it as a range query. So we split on ".." since Xapian breaks +# on punctuation anyways: +sub filename_query ($) { + join('', map { qq( dfn:"$_") } split(/\.\./, $_[0])); +} + sub find_extract_diff ($$$) { my ($self, $ibx, $want) = @_; my $srch = $ibx->search or return; @@ -187,11 +194,11 @@ sub find_extract_diff ($$$) { my $path_b = $want->{path_b}; if (path_searchable($path_b)) { - $q .= qq{ dfn:"$path_b"}; + $q .= filename_query($path_b); my $path_a = $want->{path_a}; if (path_searchable($path_a) && $path_a ne $path_b) { - $q .= qq{ dfn:"$path_a"}; + $q .= filename_query($path_a); } } -- cgit v1.2.3-24-ge0c7