Skip to content

Commit

Permalink
configd, idna encode, orginating from #3107 and other commits from th…
Browse files Browse the repository at this point in the history
…e same contributor.

Fix for #3107, although I'm doubting if we should keep supporting idna, since fixing these issues often cost us quite some time and demand for the feature doesn't appear to be very high.
  • Loading branch information
AdSchellevis committed Apr 9, 2019
1 parent ba2380a commit 00b46e0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/opnsense/service/modules/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ def __init__(self, target_root_directory="/"):
def _encode_idna(x):
""" encode string to idna, preserve leading dots
"""
tmp = b''.join([b''.join([b'.' for x in range(len(x) - len(x.lstrip('.')))]), x.lstrip('.').encode('idna')])
return tmp.decode()
try:
tmp = b''.join([b''.join([b'.' for x in range(len(x) - len(x.lstrip('.')))]), x.lstrip('.').encode('idna')])
return tmp.decode()
except UnicodeError:
# return source when unable to decode
syslog.syslog(syslog.LOG_NOTICE, "encode idna: unable to decode %s, return source" % x)
return x

def list_module(self, module_name):
""" list single module content
Expand Down

0 comments on commit 00b46e0

Please sign in to comment.