aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/credential/netrc/git-credential-netrc.perl
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim@guixotic.coop>2025-06-25 23:25:11 +0900
committerJunio C Hamano <gitster@pobox.com>2025-06-25 09:43:59 -0700
commit1926d9b6dac2cc7584362fb9275b55c2904891d3 (patch)
tree993980cb19b01d539cbef378399825d1dda772bd /contrib/credential/netrc/git-credential-netrc.perl
parentcontrib: warn for invalid netrc file ports in git-credential-netrc (diff)
downloadgit-1926d9b6dac2cc7584362fb9275b55c2904891d3.tar.gz
git-1926d9b6dac2cc7584362fb9275b55c2904891d3.zip
contrib: better support symbolic port names in git-credential-netrc
To improve support for symbolic port names in netrc files, this changes does the following: - Treat symbolic port names as ports, not protocols in git-credential-netrc - Validate the SMTP server port provided to send-email - Convert the above symbolic port names to their numerical values. Before this change, it was not possible to have a SMTP server port set to "smtps" in a netrc file (e.g. Emacs' ~/.authinfo.gpg), as it would be registered as a protocol and break the match for a "smtp" protocol host, as queried for by git-send-email. Signed-off-by: Maxim Cournoyer <maxim@guixotic.coop> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/credential/netrc/git-credential-netrc.perl')
-rwxr-xr-xcontrib/credential/netrc/git-credential-netrc.perl11
1 files changed, 7 insertions, 4 deletions
diff --git a/contrib/credential/netrc/git-credential-netrc.perl b/contrib/credential/netrc/git-credential-netrc.perl
index 09d77b4f69..3c0a532d0e 100755
--- a/contrib/credential/netrc/git-credential-netrc.perl
+++ b/contrib/credential/netrc/git-credential-netrc.perl
@@ -268,13 +268,16 @@ sub load_netrc {
next;
}
if (defined $nentry->{port}) {
- if ($nentry->{port} =~ m/^\d+$/) {
- $num_port = $nentry->{port};
- delete $nentry->{port};
- } else {
+ $num_port = Git::port_num($nentry->{port});
+ unless ($num_port) {
printf(STDERR "ignoring invalid port `%s' " .
"from netrc file\n", $nentry->{port});
}
+ # Since we've already validated and converted
+ # the port to its numerical value, do not
+ # capture it as the `protocol' value, as used
+ # to be the case for symbolic port names.
+ delete $nentry->{port};
}
# create the new entry for the credential helper protocol