diff options
author | Eric Wong <e@80x24.org> | 2022-06-20 19:27:30 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-06-21 10:39:11 +0000 |
commit | 8fda04081acde7053458023fde3b1c784cbcfc81 (patch) | |
tree | 330f61bf4cb414a778d6732f4b171686361be185 /t | |
parent | d0079a334fe2b769e4f81d6bd3c7e4346a8fa2b2 (diff) | |
download | public-inbox-8fda04081acde7053458023fde3b1c784cbcfc81.tar.gz |
Base-85 binary patches generated by git lead to many false positives, so skip over gibberish words which may occur in them. To avoid regressions in search results, continue to allow searching for exact size matches (via "literal $SIZE") and the phrase "GIT binary patch" for the mere presence of a binary patch.
Diffstat (limited to 't')
-rw-r--r-- | t/data/binary.patch | 20 | ||||
-rw-r--r-- | t/search.t | 15 |
2 files changed, 35 insertions, 0 deletions
diff --git a/t/data/binary.patch b/t/data/binary.patch new file mode 100644 index 00000000..58717abe --- /dev/null +++ b/t/data/binary.patch @@ -0,0 +1,20 @@ +From 7a1921ba7bd99c63ad6dc6ec0791691ee80e279a Mon Sep 17 00:00:00 2001 +From: BOFH <bofh@example.com> +Date: Fri, 13 May 2022 23:04:14 +0000 +Subject: [PATCH] binary patch test +Message-ID: <binary-patch-test@example> + +--- + zero | Bin 0 -> 1 bytes + 1 file changed, 0 insertions(+), 0 deletions(-) + create mode 100644 zero + +diff --git a/zero b/zero +new file mode 100644 +index 0000000000000000000000000000000000000000..f76dd238ade08917e6712764a16a22005a50573d +GIT binary patch +literal 1 +IcmZPo000310RR91 + +literal 0 +HcmV?d00001 @@ -533,6 +533,21 @@ $ibx->with_umask(sub { is($query->('s:"mail header experiments"')->[0]->{mid}, '20200418222508.GA13918@dcvr', 'Subject search reaches inside message/rfc822'); + + $doc_id = $rw->add_message(eml_load('t/data/binary.patch')); + $rw->commit_txn_lazy; + $ibx->search->reopen; + my $res = $query->('HcmV'); + is_deeply($res, [], 'no results against trailer'); + $res = $query->('IcmZPo000310RR91'); + is_deeply($res, [], 'no results against 1-byte binary patch'); + $res = $query->('"GIT binary patch"'); + is(scalar(@$res), 1, 'got binary result from "GIT binary patch"'); + is($res->[0]->{mid}, 'binary-patch-test@example', 'msgid for binary'); + my $s = $query->('"literal 1"'); + is_deeply($s, $res, 'got binary result from exact literal size'); + $s = $query->('"literal 2"'); + is_deeply($s, [], 'no results for wrong size'); }); SKIP: { |