Re: git-send-email generates mail with invalid Message-Id
On Tue, Jul 28, 2009 at 1:47 PM, Erik Faye-Lund<kusmabite@googlemail.com> wrote:
Show 8 quoted lines
> On Tue, Jul 28, 2009 at 1:38 PM, Nicolas Sebrecht<nicolas.s.dev@gmx.fr> wrote:
>> Hum, you're right. The '@' symbol is required, whatever "id-right" is.
>> My previous patch should fix it.
>
> With all due respect, I don't see how that patch fixes anything. The
> previous last-resort solution should already be just as valid, it
> assigns 'user@'+hostname to $du_part. Even if hostname is "" it should
> insert an '@', which didn't happen here.
Here's an attempt to fix the case when Sys::Hostname::hostname returns "" (domains aren't allowed to be empty if I read RFC2822 correctly). The problem with the previous attempt was that the earlier if assigned "user@" to $du_part, so the last if was never entered ($du_part was always defined).
I generally don't write Perl, so people will most likely barf all over this one, but at least it should show the concept. It might not even work.
I also suspect that it is not needed. http://search.cpan.org/~tty/kurila-1.19_0/ext/Sys-Hostname/Hostname.pm seems to indicate that it either returns something sensible or dies.
--- Untested.
git-send-email.perl | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 303e03a..baadbdb 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -742,7 +742,11 @@ sub make_message_id
}
if (not defined $du_part or $du_part eq '') {
use Sys::Hostname qw();
- $du_part = 'user@' . Sys::Hostname::hostname();
+ my $domain = Sys::Hostname::hostname();
+ if (not defined $domain or $domain eq '') {
+ $domain = 'fake.dom';
+ }
+ $du_part = "user@$domain";
}
my $message_id_template = "<%s-git-send-email-%s>";
$message_id = sprintf($message_id_template, $uniq, $du_part);
--
Erik "kusma" Faye-Lund
kusmabite@gmail.com
(+47) 986 59 656