IDNA does not work both ways

I have some IDNA encoded strings that I cannot decode. In Python I try u"xn--grohandel-shop-2fb".decode("idna")

and get the "IDNA not working" error. The same goes for "xn--sottmqqo5-lgbe9b7no0hmz9u"


I'm stumped and the Googling bug doesn't help at all.


source to share

1 answer

The error "IDNA does not access there" means that the module receives a different result when decoding and encoding the string.

After examining the source code for the IDNA Python module, the "IDNA does not access there" error is raised on line 139 if the module cannot recreate the input. In the decoding function, the input is separated by dots and each part is converted to toUnicode

. There the text is decoded, but before the result is returned, it encodes the result and compares it to the input and raises an error if it is not the same: "this is not a circular motion" or encode(decode(text)) != text


In the error message, you will also get the two lines you tried to compare, in the first example:

UnicodeError: ('IDNA does not round-trip', 'xn--grohandel-shop-2fb', 'grosshandel-shop')


You get the error because it converted ß

to "großhandel-shop" on ss

to "grosshandel-shop". The symbol ß

was added to .de

-tld at the end of 2010
, so this is a bug. Before the change ß

had to be changed to ss


Your second example is probably corrupted because it converts to: "đsottĤmqĐqǗoĔ ⢠5"



All Articles