From 32df79bb83dc0a6760ce1cebfd6e416bb86033a4 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sun, 8 Apr 2018 10:44:47 -0700 Subject: [PATCH] Only sanitize script output when viewing the logs in the UI --- plexpy/notifiers.py | 8 +++++--- plexpy/webserve.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index 51e94010..85f45607 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -2933,6 +2933,8 @@ class SCRIPTS(Notifier): '.sh': '' } + self.arg_overrides = ('python2', 'python3', 'python', 'pythonw', 'php', 'ruby', 'perl') + def list_scripts(self): scriptdir = self.config['script_folder'] scripts = {'': ''} @@ -2994,12 +2996,12 @@ class SCRIPTS(Notifier): return False if error: - err = '\n '.join([helpers.sanitize(l) for l in error.splitlines()]) + err = '\n '.join([l for l in error.splitlines()]) logger.error(u"Tautulli Notifiers :: Script error: \n %s" % err) return False if output: - out = '\n '.join([helpers.sanitize(l) for l in output.splitlines()]) + out = '\n '.join([l for l in output.splitlines()]) logger.debug(u"Tautulli Notifiers :: Script returned: \n %s" % out) if not self.script_killed: @@ -3055,7 +3057,7 @@ class SCRIPTS(Notifier): # Allow overrides for shitty systems if prefix and script_args: - if script_args[0] in ('python2', 'python', 'pythonw', 'php', 'ruby', 'perl'): + if script_args[0] in self.arg_overrides: script[0] = script_args[0] del script_args[0] diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 12236320..69398e2e 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -2310,13 +2310,13 @@ class WebInterface(object): try: temp_loglevel_and_time = l.split(' - ', 1) loglvl = temp_loglevel_and_time[1].split(' ::', 1)[0].strip() - msg = unicode(l.split(' : ', 1)[1].replace('\n', ''), 'utf-8') + msg = helpers.sanitize(unicode(l.split(' : ', 1)[1].replace('\n', ''), 'utf-8')) fa([temp_loglevel_and_time[0], loglvl, msg]) except IndexError: # Add traceback message to previous msg. tl = (len(filt) - 1) n = len(l) - len(l.lstrip(' ')) - ll = ' ' * (2 * n) + unicode(l[n:], 'utf-8') + ll = ' ' * (2 * n) + helpers.sanitize(unicode(l[n:], 'utf-8')) filt[tl][2] += '
' + ll continue