Fix detection of encoding in zonemgr option

Ticket: https://fedorahosted.org/freeipa/ticket/4762
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Martin Basti 2014-11-24 12:46:37 +01:00 committed by Jan Cholasta
parent 8ef191448f
commit 880f1e5c27

View File

@ -401,13 +401,14 @@ def zonemgr_callback(option, opt_str, value, parser):
"""
Properly validate and convert --zonemgr Option to IA5String
"""
# validate the value first
try:
# IDNA support requires unicode
value = value.decode(sys.stdin.encoding)
validate_zonemgr_str(value)
except ValueError, e:
parser.error("invalid zonemgr: " + unicode(e))
if value is not None:
# validate the value first
try:
# IDNA support requires unicode
value = value.decode(getattr(sys.stdin, 'encoding', 'utf-8'))
validate_zonemgr_str(value)
except ValueError, e:
parser.error("invalid zonemgr: " + unicode(e))
parser.values.zonemgr = value