user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] nntpd: fix LISTGROUP with range
@ 2022-11-28 20:25 mephi42
  2022-11-28 20:59 ` Eric Wong
  0 siblings, 1 reply; 3+ messages in thread
From: mephi42 @ 2022-11-28 20:25 UTC (permalink / raw)
  To: meta; +Cc: mephi42

This reverts 0c62cffc2389 ("nntp: listgroup_range_i: remove useless
`map' op") and adds a test that demonstrates the breakage: the server
returns lines like

    ARRAY(0x556dace73f08)

instead of message numbers.

Fixes: 0c62cffc2389 ("nntp: listgroup_range_i: remove useless `map' op")
---
 lib/PublicInbox/NNTP.pm |  2 +-
 t/nntpd.t               | 11 +++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index ceaf05f6..dd33a232 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -188,7 +188,7 @@ sub listgroup_range_i {
 	my ($self, $beg, $end) = @_;
 	my $r = $self->{ibx}->mm(1)->msg_range($beg, $end, 'num');
 	scalar(@$r) or return;
-	$self->msg_more(join("\r\n", @$r, ''));
+	$self->msg_more(join('', map { "$_->[0]\r\n" } @$r));
 	1;
 }
 
diff --git a/t/nntpd.t b/t/nntpd.t
index d352c3c1..058bd796 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -93,6 +93,13 @@ close $cfgfh or BAIL_OUT;
 	is_deeply([$n->group($group)], [ qw(0 1 1), $group ], 'GROUP works');
 	is_deeply($n->listgroup($group), [1], 'listgroup OK');
 	# TODO: Net::NNTP::listgroup does not support range at the moment
+	my $s = tcp_connect($sock);
+	sysread($s, my $buf, 4096);
+	is($buf, "201 " . hostname . " ready - post via email\r\n",
+		'got greeting');
+	syswrite($s, "LISTGROUP $group 1-1\r\n");
+	$buf = read_til_dot($s);
+	like($buf, qr/\r\n1\r\n/s, 'LISTGROUP with range works');
 
 	{
 		my $expect = [ qw(Subject: From: Date: Message-ID:
@@ -120,8 +127,8 @@ close $cfgfh or BAIL_OUT;
 		'references' => '<reftabsqueezed>',
 	);
 
-	my $s = tcp_connect($sock);
-	sysread($s, my $buf, 4096);
+	$s = tcp_connect($sock);
+	sysread($s, $buf, 4096);
 	is($buf, "201 " . hostname . " ready - post via email\r\n",
 		'got greeting');
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-28 23:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-28 20:25 [PATCH] nntpd: fix LISTGROUP with range mephi42
2022-11-28 20:59 ` Eric Wong
2022-11-28 23:11   ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).