user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: mephi42 <mephi42@gmail.com>
To: meta@public-inbox.org
Cc: mephi42 <mephi42@gmail.com>
Subject: [PATCH] nntpd: fix LISTGROUP with range
Date: Mon, 28 Nov 2022 21:25:21 +0100	[thread overview]
Message-ID: <20221128202521.62476-1-mephi42@gmail.com> (raw)

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


             reply	other threads:[~2022-11-28 20:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28 20:25 mephi42 [this message]
2022-11-28 20:59 ` [PATCH] nntpd: fix LISTGROUP with range Eric Wong
2022-11-28 23:11   ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221128202521.62476-1-mephi42@gmail.com \
    --to=mephi42@gmail.com \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).