diff options
author | Eric Wong <e@yhbt.net> | 2020-06-10 07:05:02 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-06-13 07:55:45 +0000 |
commit | cd389aac52936c82f3416b3ceefe21e1250b8a3e (patch) | |
tree | e68b068c3ec0d7aba3df80304fcb6cb398c1d589 /t | |
parent | f77b21173e730a3daa8f5eed6d73835a682b3f04 (diff) | |
download | public-inbox-cd389aac52936c82f3416b3ceefe21e1250b8a3e.tar.gz |
NNTP and IMAP both require CRLF conversions on the wire. They're also the only components which care about $smsg->{bytes}, so store the CRLF-adjusted value in over.sqlite3 and Xapian DBs.. This will allow us to optimize RFC822.SIZE fetch item in IMAP without triggering size mismatch errors in some clients' default configurations (e.g. Mail::IMAPClient), but not most others. It could also fix hypothetical problems with NNTP clients that report discrepancies between overview and article data.
Diffstat (limited to 't')
-rw-r--r-- | t/import.t | 5 | ||||
-rw-r--r-- | t/nntpd.t | 5 | ||||
-rw-r--r-- | t/search.t | 8 |
3 files changed, 15 insertions, 3 deletions
@@ -32,8 +32,9 @@ like($im->add($mime, undef, $smsg), qr/\A:[0-9]+\z/, 'added one message'); if ($v2) { like($smsg->{blob}, qr/\A[a-f0-9]{40}\z/, 'got last object_id'); - is($mime->as_string, ${$smsg->{-raw_email}}, 'string matches'); - is($smsg->{bytes}, length(${$smsg->{-raw_email}}), 'length matches'); + my $raw_email = $smsg->{-raw_email}; + is($mime->as_string, $$raw_email, 'string matches'); + is($smsg->{raw_bytes}, length($$raw_email), 'length matches'); my @cmd = ('git', "--git-dir=$git->{git_dir}", qw(hash-object --stdin)); my $in = tempfile(); print $in $mime->as_string or die "write failed: $!"; @@ -73,7 +73,10 @@ EOF my $list_id = $addr; $list_id =~ s/@/./; $mime->header_set('List-Id', "<$list_id>"); - $len = length($mime->as_string); + my $str = $mime->as_string; + $str =~ s/(?<!\r)\n/\r\n/sg; + $len = length($str); + undef $str; $im->add($mime); $im->done; if ($version == 1) { @@ -59,6 +59,14 @@ sub oct_is ($$$) { } } +{ + my $crlf_adjust = \&PublicInbox::SearchIdx::crlf_adjust; + is($crlf_adjust->("hi\r\nworld\r\n"), 0, 'no adjustment needed'); + is($crlf_adjust->("hi\nworld\n"), 2, 'LF-only counts two CR'); + is($crlf_adjust->("hi\r\nworld\n"), 1, 'CRLF/LF-mix 1 counts 1 CR'); + is($crlf_adjust->("hi\nworld\r\n"), 1, 'CRLF/LF-mix 2 counts 1 CR'); +} + $ibx->with_umask(sub { my $root = PublicInbox::Eml->new(<<'EOF'); Date: Fri, 02 Oct 1993 00:00:00 +0000 |