user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/8] net_reader: escape nasty chars from Net::NNTP->message
Date: Mon, 22 Mar 2021 07:53:56 +0000	[thread overview]
Message-ID: <20210322075402.27834-3-e@80x24.org> (raw)
In-Reply-To: <20210322075402.27834-1-e@80x24.org>

Net::Cmd::message (used by Net::NNTP) does no escaping at all,
so "\r" was causing confusing/nonsensical error messages when
I tried to import from the wrong group.
---
 lib/PublicInbox/NetReader.pm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index d3094fc7..bc211029 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -7,11 +7,15 @@ use strict;
 use v5.10.1;
 use parent qw(Exporter PublicInbox::IPC);
 use PublicInbox::Eml;
-
 our %IMAPflags2kw = map {; "\\\u$_" => $_ } qw(seen answered flagged draft);
 
 our @EXPORT = qw(uri_section imap_uri nntp_uri);
 
+sub ndump {
+	require Data::Dumper;
+	Data::Dumper->new(\@_)->Useqq(1)->Terse(1)->Dump;
+}
+
 # returns the git config section name, e.g [imap "imaps://user@example.com"]
 # without the mailbox, so we can share connections between different inboxes
 sub uri_section ($) {
@@ -530,7 +534,7 @@ sub _nntp_fetch_all ($$$) {
 	my $sec = uri_section($uri);
 	my ($nr, $beg, $end) = $nn->group($group);
 	unless (defined($nr)) {
-		chomp(my $msg = $nn->message);
+		my $msg = ndump($nn->message);
 		return "E: GROUP $group <$sec> $msg";
 	}
 
@@ -566,7 +570,7 @@ sub _nntp_fetch_all ($$$) {
 		}
 		my $raw = $nn->article($art);
 		unless (defined($raw)) {
-			my $msg = $nn->message;
+			my $msg = ndump($nn->message);
 			if ($nn->code == 421) { # pseudo response from Net::Cmd
 				$err = "E: $msg";
 				last;

  parent reply	other threads:[~2021-03-22  7:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22  7:53 [PATCH 0/8] lei input handling improvements Eric Wong
2021-03-22  7:53 ` [PATCH 1/8] lei: support -c <name>=<value> to overrides Eric Wong
2021-03-22  7:53 ` Eric Wong [this message]
2021-03-22  7:53 ` [PATCH 3/8] lei: share input code between convert and import Eric Wong
2021-03-22  7:53 ` [PATCH 4/8] lei: simplify workers_start and callers Eric Wong
2021-03-22  7:53 ` [PATCH 5/8] mbox_reader: add ->reads method to avoid nonsensical formats Eric Wong
2021-03-22  7:54 ` [PATCH 6/8] lei_input: common filehandle reader for eml + mbox Eric Wong
2021-03-22  7:54 ` [PATCH 7/8] lei_input: drop "From " line on single "eml" (message/rfc822) Eric Wong
2021-03-22  7:54 ` [PATCH 8/8] lei import: ignore Status headers in "eml" messages 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=20210322075402.27834-3-e@80x24.org \
    --to=e@80x24.org \
    --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).