# HG changeset patch # User Marti Raudsepp # Date 2009-11-05 09:49:28 # Node ID f0e99a2eac76cfff7be69b584d3c825ff9e1b467 # Parent 2f1ab7f77ddc0d8a0cd4705ab80565694d7c77f9 patchbomb: fix handling of email addresses with Unicode domains (IDNA) dom.encode('idna') requires dom to be a Unicode string. diff --git a/mercurial/mail.py b/mercurial/mail.py --- a/mercurial/mail.py +++ b/mercurial/mail.py @@ -169,7 +169,7 @@ def addressencode(ui, address, charsets= try: acc, dom = addr.split('@') acc = acc.encode('ascii') - dom = dom.encode('idna') + dom = dom.decode(encoding.encoding).encode('idna') addr = '%s@%s' % (acc, dom) except UnicodeDecodeError: raise util.Abort(_('invalid email address: %s') % addr) diff --git a/tests/test-patchbomb b/tests/test-patchbomb --- a/tests/test-patchbomb +++ b/tests/test-patchbomb @@ -170,3 +170,10 @@ hg email --date '1970-1-1 0:1' -n --flag echo "% test multiple flags for multiple patches" hg email --date '1970-1-1 0:1' -n --flag fooFlag --flag barFlag -f quux -t foo \ -c bar -s test -r 0:1 | fixheaders + +echo "% test multi-byte domain parsing" +UUML=`echo -en '\xfc'` +export HGENCODING=iso-8859-1 +hg email --date '1980-1-1 0:1' -m tmp.mbox -f quux -t "bar@${UUML}nicode.com" \ + -s test -r 0 +cat tmp.mbox | fixheaders diff --git a/tests/test-patchbomb.out b/tests/test-patchbomb.out --- a/tests/test-patchbomb.out +++ b/tests/test-patchbomb.out @@ -1469,3 +1469,34 @@ diff -r 8580ff50825a -r 97d72e5f12c7 b @@ -0,0 +1,1 @@ +b +% test multi-byte domain parsing +This patch series consists of 1 patches. + + +Writing [PATCH] test ... +From quux Tue Jan 1 00:01:01 1980 +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Subject: [PATCH] test +X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab +Message-Id: <8580ff50825a50c8f716.315532860@ +User-Agent: Mercurial-patchbomb +Date: Tue, 01 Jan 1980 00:01:00 +0000 +From: quux +To: bar@xn--nicode-2ya.com + +# HG changeset patch +# User test +# Date 1 0 +# Node ID 8580ff50825a50c8f716709acdf8de0deddcd6ab +# Parent 0000000000000000000000000000000000000000 +a + +diff -r 000000000000 -r 8580ff50825a a +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/a Thu Jan 01 00:00:01 1970 +0000 +@@ -0,0 +1,1 @@ ++a + +