Bug 745 - unbound.py - idn2dname throws UnicodeError when idnname contains trailing dot
unbound.py - idn2dname throws UnicodeError when idnname contains trailing dot
Status: RESOLVED FIXED
Product: unbound
Classification: Unclassified
Component: server
1.5.7
Other All
: P5 trivial
Assigned To: unbound team
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-29 21:01 CET by matt
Modified: 2016-03-02 09:20 CET (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description matt 2016-02-29 21:01:01 CET
idn2dname() in unbound.py throws a UnicodeError ("label empty or too long") if the idnname contains a trailing (or leading) dot. A trailing dot is a valid DNS name so there should be no exception generated for this sort of name.
Comment 1 Wouter Wijngaards 2016-03-02 09:20:08 CET
Hi Matt,

Your bug has been fixed.  The fix is in code repository, (and did not make it into the release 1.5.8 that came out today, that was frozen for changes last week).

The patch (from my colleague Ralph) is short:
Index: libunbound/python/libunbound.i
===================================================================
--- libunbound/python/libunbound.i	(revision 3641)
+++ libunbound/python/libunbound.i	(working copy)
@@ -945,7 +945,7 @@
            :param idnname: (unicode string) IDN name
            :returns: (string) domain name
         """
-        return '.'.join([encodings.idna.ToASCII(a) for a in idnname.split('.')])
+        return '.'.join([encodings.idna.ToASCII(a) if a else '' for a in idnname.split('.')])
 
     def dname2idn(name):
         """Converts canonic domain name in IDN format to unicode string


Best regards, Wouter