From: Jari Aalto <jari.aalto@cante.net>
To: git@vger.kernel.org
Subject: [PATCH] git-send-email.perl: add maildomain_sanitize()
Date: Tue, 13 Apr 2010 14:35:26 +0300 [thread overview]
Message-ID: <87bpdnwpoh.fsf_-_@jondo.cante.net> (raw)
In-Reply-To: 87ljcrwxni.fsf_-_@jondo.cante.net
Move duplicate maildomain checks to a single subroutine.
Require that a FQDN contains at least one period.
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
git-send-email.perl | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
Here is improved version 2 (use "tab" for indentation).
-- Jari
>Re: [PATCH 1/3] send-email: Don't use FQDNs without a '.'
>Junio C Hamano <gitster@pobox.com> writes:
>> Brian Gernhardt <brian@gernhardtsoftware.com> writes:
>
>> $maildomain = $domain
>> - unless $^O eq 'darwin' && $domain =~ /\.local$/;
>> + unless $^O eq 'darwin' && $domain =~ /\.local$/
>> + or $domain !~ /\./;
>
> [Junio] It would become *much* easier to read if we stop using the statement
> modifier, and write it in a more straightforward way:
>
> unless (($^O eq 'darwin' && $domain =~ /\.local$/)
> || $domain !~ /\./) {
> $maildomain = $domain;
> }
>
> as the condition seems to have grown large enough to exceed "by the way
> don't do this under this narrow condition", which is what statement
> modifiers are designed to be used. Also mixing && and or that have
> different precedence taxes readers' brainpower unnecessarily.
>
> I also think that this particular exception logic should probably be in a
> separate helper function that is called from the two places.
>
> Jari, you are the last person who touched code around this area. What do
> you think?
diff --git a/git-send-email.perl b/git-send-email.perl
index ce569a9..0e8f18c 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -863,14 +863,28 @@ sub sanitize_address
# This maildomain*() code is based on ideas in Perl library Test::Reporter
# /usr/share/perl5/Test/Reporter/Mail/Util.pm ==> sub _maildomain ()
+sub maildomain_sanitize
+{
+ local $_ = shift;
+
+ # On Mac, the the domain name is not necessarily in FQDN format
+ # Require a period in the string
+
+ if ( $^O eq 'darwin' and /\.local$/ ) {
+ # Nope, pass this one.
+ }
+ elsif ( /\./ ) {
+ $_;
+ }
+}
+
sub maildomain_net
{
my $maildomain;
if (eval { require Net::Domain; 1 }) {
my $domain = Net::Domain::domainname();
- $maildomain = $domain
- unless $^O eq 'darwin' && $domain =~ /\.local$/;
+ $maildomain = maildomain_sanitize($domain);
}
return $maildomain;
@@ -887,8 +901,7 @@ sub maildomain_mta
my $domain = $smtp->domain;
$smtp->quit;
- $maildomain = $domain
- unless $^O eq 'darwin' && $domain =~ /\.local$/;
+ $maildomain = maildomain_sanitize($domain);
last if $maildomain;
}
--
1.7.0
next prev parent reply other threads:[~2010-04-13 11:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-09 5:11 [PATCH 0/3] send-email: --smtp-domain improvements Brian Gernhardt
2010-04-09 5:11 ` [PATCH 1/3] send-email: Don't use FQDNs without a '.' Brian Gernhardt
2010-04-09 5:36 ` Junio C Hamano
2010-04-13 8:43 ` [PATCH] git-send-email.perl: Add sub maildomain_sanitize Jari Aalto
2010-04-13 11:35 ` Jari Aalto [this message]
2010-04-15 12:47 ` [PATCH] git-send-email.perl: add maildomain_sanitize() Jakub Narebski
2010-04-16 15:49 ` [PATCH v2] git-send-email.perl: Add sub maildomain_sanitize Jari Aalto
2010-04-16 16:11 ` Jakub Narebski
2010-04-16 17:00 ` Start encouraging English.pm (Was: [PATCH v2] git-send-email.perl: Add sub maildomain_sanitize) Jari Aalto
2010-04-09 5:11 ` [PATCH 2/3] Document send-email --smtp-domain Brian Gernhardt
2010-04-09 5:11 ` [PATCH 3/3] send-email: Add sendemail.smtpdomain Brian Gernhardt
2010-04-09 6:56 ` Jakub Narebski
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bpdnwpoh.fsf_-_@jondo.cante.net \
--to=jari.aalto@cante.net \
--cc=git@vger.kernel.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.