git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-send-email generates mail with invalid Message-Id

From
Erik Faye-Lund <kusmabite@googlemail.com>
Date
Jul 28, 2009, 12:10 UTC
Message-ID
<40aa078e0907280510s1afee3ddw3a9333620a3c7d7a@mail.gmail.com>
In-Reply-To
<40aa078e0907280447p4ed92133jb5e586fb0ca40ef2@mail.gmail.com>
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
Previous: Erik Faye-LundNext: Nicolas Sebrecht
Message 12 of 13 in “git-send-email generates mail with invalid Message-Id”
  1. Frans PopJul 28, 2009
  2. Erik Faye-LundJul 28, 2009
  3. Thomas RastJul 28, 2009
  4. Erik Faye-LundJul 28, 2009
  5. Thomas RastJul 28, 2009
  6. Frans PopJul 28, 2009
  7. Frans PopJul 28, 2009
  8. Nicolas SebrechtJul 28, 2009
  9. Frans PopJul 28, 2009
  10. Nicolas SebrechtJul 28, 2009
  11. Erik Faye-LundJul 28, 2009
  12. Erik Faye-LundJul 28, 2009
  13. Nicolas SebrechtJul 28, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.