Handle unicode script arguments

This commit is contained in:
JonnyWong16 2018-06-28 18:37:07 -07:00
parent b248dbacf2
commit a3ead41990
2 changed files with 3 additions and 3 deletions

View file

@ -1028,7 +1028,7 @@ def build_notify_text(subject='', body='', notify_action=None, parameters=None,
if agent_id == 15: if agent_id == 15:
try: try:
script_args = [custom_formatter.format(unicode(arg), **parameters) for arg in shlex.split(subject)] script_args = [custom_formatter.format(arg.decode('utf-8'), **parameters) for arg in shlex.split(subject.encode('utf-8'))]
except LookupError as e: except LookupError as e:
logger.error(u"Tautulli NotificationHandler :: Unable to parse parameter %s in script argument. Using fallback." % e) logger.error(u"Tautulli NotificationHandler :: Unable to parse parameter %s in script argument. Using fallback." % e)
script_args = [] script_args = []

View file

@ -3085,12 +3085,12 @@ class SCRIPTS(Notifier):
# For manual notifications # For manual notifications
if script_args and isinstance(script_args, basestring): if script_args and isinstance(script_args, basestring):
# attemps for format it for the user # attemps for format it for the user
script_args = shlex.split(script_args) script_args = [arg.decode('utf-8') for arg in shlex.split(script_args.encode('utf-8'))]
# Windows handles unicode very badly. # Windows handles unicode very badly.
# https://bugs.python.org/issue19264 # https://bugs.python.org/issue19264
if script_args and os.name == 'nt': if script_args and os.name == 'nt':
script_args = [s.encode(plexpy.SYS_ENCODING, 'ignore') for s in script_args] script_args = [arg.encode(plexpy.SYS_ENCODING, 'ignore') for arg in script_args]
# Allow overrides for shitty systems # Allow overrides for shitty systems
if prefix and script_args: if prefix and script_args: