Gnus development mailing list
 help / color / mirror / Atom feed
From: Reiner Steib <reinersteib+gmane@imap.cc>
To: <ding@gnus.org>
Subject: Avoid calling idna-to-ascii on ASCII domain names (was: Gnus generates an invalid To header)
Date: Sat, 01 Dec 2007 12:56:59 +0100	[thread overview]
Message-ID: <v9fxymbpbo.fsf@marauder.physik.uni-ulm.de> (raw)
In-Reply-To: <87prxxw534.fsf@denkblock.local>

[ Resending.  The first message didn't reach the list, AFAICS.
  In the meantime, I have installed the latter patch. ]

On Mon, Nov 26 2007, Elias Oltmanns wrote:

> Tassilo Horn <tassilo@member.fsf.org> wrote:
>> Reiner Steib <reinersteib+gmane@imap.cc> writes:
>>> By edebugging `message-idna-to-ascii-rhs-1', I found that it calls
>>> (idna-to-ascii rhs) with `rhs' = "" because the right hand side of
>>> "tierklinikkaiserbergduisburg" is the empty string.  Maybe message
>>> should just return the same header instead if calling `idna-to-ascii'
>>> if `rhs' is empty?
[...]
> What Reiner suggests is fixing a bug on Gnus' part and a priori the
> right thing to do.  

This patch avoids calling `idna-to-ascii' if the domain part is empty:

--8<---------------cut here---------------start------------->8---
--- message.el	06 Nov 2007 00:13:10 +0100	7.228
+++ message.el	28 Nov 2007 22:15:16 +0100	
@@ -5547,7 +5547,9 @@
 			(mapcar 'downcase
 				(mapcar
 				 'car (mail-header-parse-addresses field))))))
-	(setq ace (downcase (idna-to-ascii rhs)))
+	(setq ace (if (equal rhs "")
+		      ""
+		    (downcase (idna-to-ascii rhs))))
 	(when (and (not (equal rhs ace))
 		   (or (not (eq message-use-idna 'ask))
 		       (y-or-n-p (format "Replace %s with %s in %s:? "
--8<---------------cut here---------------end--------------->8---

This one avoids calling `idna-to-ascii' if the domain part contains
only ASCII characters.  I think we should apply it.  Does anyone see a
problem with it?

--8<---------------cut here---------------start------------->8---
--- message.el	06 Nov 2007 00:13:10 +0100	7.228
+++ message.el	28 Nov 2007 22:21:47 +0100	
@@ -5547,7 +5547,9 @@
 			(mapcar 'downcase
 				(mapcar
 				 'car (mail-header-parse-addresses field))))))
-	(setq ace (downcase (idna-to-ascii rhs)))
+	(setq ace (if (string-match "\\`[[:ascii:]]+\\'" rhs)
+		      rhs
+		    (downcase (idna-to-ascii rhs))))
 	(when (and (not (equal rhs ace))
 		   (or (not (eq message-use-idna 'ask))
 		       (y-or-n-p (format "Replace %s with %s in %s:? "
--8<---------------cut here---------------end--------------->8---

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/



      parent reply	other threads:[~2007-12-01 11:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-24 11:47 Gnus generates an invalid To header Tassilo Horn
2007-11-24 13:03 ` Reiner Steib
2007-11-26 11:25   ` Tassilo Horn
2007-11-26 12:42     ` Elias Oltmanns
2007-11-28 21:42       ` Reiner Steib
2007-12-01 11:56       ` Reiner Steib [this message]

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=v9fxymbpbo.fsf@marauder.physik.uni-ulm.de \
    --to=reinersteib+gmane@imap.cc \
    --cc=Reiner.Steib@gmx.de \
    --cc=ding@gnus.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).