From 330e8be4e5237514e1d94eea81bf875be5b69fd8 Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Tue, 21 Apr 2015 11:56:52 +0200 Subject: [PATCH] Decode output of scripts from utf8 to unicode. --- doc/MANUAL.md | 2 ++ src/scriptform.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/MANUAL.md b/doc/MANUAL.md index cc6ef31..525c4fc 100644 --- a/doc/MANUAL.md +++ b/doc/MANUAL.md @@ -242,6 +242,8 @@ FIXME client's browser. This allows you to output images, binary files, etc to the client. The script must include the proper headers and body itself. +**All output is assumed to be UTF8, regardless of system encoding!** + If the script's exit code is 0, the output of the script (stdout) is captured and shown to the user in the browser. diff --git a/src/scriptform.py b/src/scriptform.py index b4f9fad..4f5e6e7 100755 --- a/src/scriptform.py +++ b/src/scriptform.py @@ -822,12 +822,12 @@ class ScriptFormWebApp(WebAppHandler): result = form_config.callback(form_name, form_values, self) if result: if result['exitcode'] != 0: - msg = u'{0}'.format(cgi.escape(result['stderr'])) + msg = u'{0}'.format(cgi.escape(result['stderr'].decode('utf8'))) else: if form_def.output == 'escaped': - msg = u'
{0}
'.format(cgi.escape(result['stdout'])) + msg = u'
{0}
'.format(cgi.escape(result['stdout'].decode('utf8'))) else: - msg = result['stdout'] + msg = result['stdout'].decode('utf8') output = html_submit_response.format( header=html_header.format(title=form_config.title),