about summary refs log tree commit homepage
path: root/t/search.t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-02-11 12:57:28 +0700
committerEric Wong <e@80x24.org>2021-02-12 22:58:50 -0400
commitc471b946ef629cf3db9043081a1aeaa189436f6b (patch)
tree88d9a38b81b6d32ddfba81158b004cc481607f05 /t/search.t
parent376778b910cdf787d6e08cfd11acab26118899f4 (diff)
downloadpublic-inbox-c471b946ef629cf3db9043081a1aeaa189436f6b.tar.gz
The cleanup doesn't seem to matter, I initially thought I needed
to handle "" (two double quotes) explicitly because that's what
Xapian does to escape a double quote inside a double-quoted
phrase.  It turns out we only need to be able to pass phrases
through to Xapian unmodified, and the existing group of
["\x{201c}\x{201d}] is sufficient for our purposes.
Diffstat (limited to 't/search.t')
-rw-r--r--t/search.t21
1 files changed, 21 insertions, 0 deletions
diff --git a/t/search.t b/t/search.t
index effba1df..124c9acf 100644
--- a/t/search.t
+++ b/t/search.t
@@ -603,6 +603,27 @@ SKIP: {
         is($qs, qq[f:bob "hello world" d:19931002..20101002],
                 'post-phrase date corrected');
 
+        # Xapian uses "" to escape " inside phrases, we don't explictly
+        # handle that, but are able to pass the result through unchanged
+        for my $pair (["\x{201c}", "\x{201d}"], ['"', '"']) {
+                my ($x, $y) = @$pair;
+                $orig = $qs = qq[${x}hello d:1993-10-02.."" world$y];
+                $s->query_approxidate($g, $qs);
+                is($qs, $orig, 'phrases unchanged \x'.ord($x).'-\x'.ord($y));
+
+                $s->query_approxidate($g, my $tmp = "$qs d:..2010-10-02");
+                is($tmp, "$orig d:..20101002",
+                        'two phrases did not throw off date parsing');
+
+                $orig = $qs = qq[${x}hello d:1993-10-02..$y$x world$y];
+                $s->query_approxidate($g, $qs);
+                is($qs, $orig, 'phrases unchanged \x'.ord($x).'-\x'.ord($y));
+
+                $s->query_approxidate($g, $tmp = "$qs d:..2010-10-02");
+                is($tmp, "$orig d:..20101002",
+                        'two phrases did not throw off date parsing');
+        }
+
         my $x_days_ago = strftime('%Y%m%d', gmtime(time - (5 * 86400)));
         $orig = $qs = qq[broken d:5.days.ago..];
         $s->query_approxidate($g, $qs);