From: Eric Wong <e@80x24.org>
Date: Sat, 12 Jun 2021 00:10:45 +0000 (+0000)
Subject: net_reader: canonicalize URL args on add_url
X-Git-Tag: v1.7.0~588
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=d1dbf32d5b747deb4610f98b0befdb8b6a32243a;p=public-inbox.git

net_reader: canonicalize URL args on add_url

This fixes cases when users specify an IMAP or NNTP URL
with standard port numbers explicitly.

In other words, this allows users to use
"lei ls-mail-source nntps://public-inbox.org:563/" and
"lei ls-mail-source imaps://public-inbox.org:993/"
without hitting "BUG:" errors.
---

diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index bcc6cbf0..30784199 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -371,8 +371,10 @@ sub add_url {
 	my ($self, $arg, $ls_ok) = @_;
 	my $uri;
 	if ($uri = imap_uri($arg, $ls_ok)) {
+		$_[1] = $$uri; # canonicalized
 		push @{$self->{imap_order}}, $uri;
 	} elsif ($uri = nntp_uri($arg, $ls_ok)) {
+		$_[1] = $$uri; # canonicalized
 		push @{$self->{nntp_order}}, $uri;
 	} else {
 		push @{$self->{unsupported_url}}, $arg;