Change function _is_allowed() to check one option at a time.
parent
72b74d1960
commit
c477033506
34
gnupg.py
34
gnupg.py
|
@ -816,16 +816,30 @@ def _is_allowed(input):
|
||||||
except AssertionError as ae: ## 'as' syntax requires python>=2.6
|
except AssertionError as ae: ## 'as' syntax requires python>=2.6
|
||||||
raise UsageError(ae.message)
|
raise UsageError(ae.message)
|
||||||
|
|
||||||
try:
|
## if we got a list of args, join them
|
||||||
underscored = _underscore(input)
|
if not isinstance(input, str):
|
||||||
assert underscored in _allowed
|
input = ' '.join([x for x in input])
|
||||||
except AssertionError as ae:
|
|
||||||
logger.warn("Dropping option '%s'..." % _fix_unsafe(underscored))
|
if isinstance(input, str):
|
||||||
raise ProtectedOption("Option '%s' not supported."
|
if input.find('_') > 0:
|
||||||
% _fix_unsafe(underscored))
|
if not input.startswith('--'):
|
||||||
else:
|
hyphenated = _hyphenate(input, add_prefix=True)
|
||||||
logger.msg("Got allowed option '%s'." % _fix_unsafe(underscored))
|
else:
|
||||||
return input
|
hyphenated = _hyphenate(input)
|
||||||
|
else:
|
||||||
|
hyphenated = input
|
||||||
|
try:
|
||||||
|
assert hyphenated in _allowed
|
||||||
|
except AssertionError as ae:
|
||||||
|
logger.warn("Dropping option '%s'..."
|
||||||
|
% _fix_unsafe(hyphenated))
|
||||||
|
raise ProtectedOption("Option '%s' not supported."
|
||||||
|
% _fix_unsafe(hyphenated))
|
||||||
|
else:
|
||||||
|
logger.debug("Got allowed option '%s'."
|
||||||
|
% _fix_unsafe(hyphenated))
|
||||||
|
return input
|
||||||
|
return None
|
||||||
|
|
||||||
def _sanitise(*args, **kwargs):
|
def _sanitise(*args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue