Subject: [I18n-discuss] Is this an A-label or what?

From: "John R Levine" <[email-masked]>
Date: 13 Feb 2019 10:42:13 -0500

This does what you'd expect, two A-labels turn into two U-labels:

>>> idn2.atou('xn--eckwd4c7c.xn--zckzah')
'ドメイン.テスト'

But someone added a space at the end.  Gnu idn2 decodes it as punycode, 
presumably using some implicit negative code value for the space:

>>> idn2.atou('xn--eckwd4c7c.xn--zckzah ')
'ドメイン.テニスト'

The existing python code barfs because it doesn't expect a space:

idna.decode('xn--eckwd4c7c.xn--zckzah ')
IndexError: string index out of range

The punycode algorithm will never create a label with a space at the end, 
If you see one do you decode it anyway?  Treat it as some random ASCII 
label and pass it through?  Reject it because it looks sort of like an 
A-label but it's not a hostname?

Regards,
John Levine, [email-masked], Taughannock Networks, Trumansburg NY
Please consider the environment before reading this e-mail. https://jl.ly

---

From: Martin J. Dürst <[email-masked]>
Date: Thu, 14 Feb 2019 06:25:41 +0000

>>>> idn2.atou('xn--eckwd4c7c.xn--zckzah ')

Just for those who don't read Japanese, and don't trust their eyes with 
details in foreign scripts: The two results are clearly different. The 
first reads "domain.test", the second reads "domain.tenist" (or some 
such, obviously, "tenist" or "tenisuto" in a more literal transcription 
is not a word). The "ニ" is clearly superfluous.

> IndexError: string index out of range

That's a good thing to do.

> The punycode algorithm will never create a label with a space at the 
> end, If you see one do you decode it anyway?  Treat it as some random 
> ASCII label and pass it through?  Reject it because it looks sort of 
> like an A-label but it's not a hostname?

I could expect a library in a some more lenient language to just ignore 
the space. Using the space as part of the calculation seems really 
weird. Of course Python, being a rather strict language, barfs.

Regards,   Martin.