From 13ca1b923e479905f9d1debdea6125be92f44808 Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Mon, 19 Mar 2012 16:33:16 -0700 Subject: Strip out characters that should be escaped from console output Minidom has a bug where it doesn't escape characters < 32 correctly. That is http://bugs.python.org/issue5752 We probably want to move to lxml anyway. Console-output is particularly likely to have invalid characters, because ANSI output include the ESC character (0x1B). Strip out invalid characters for this case (although the problem is still present anywhere we write a string in the XML) Bug #939386 Change-Id: I4689c0f26fb4887867a8d5b6f5e5fb5e2590be91 --- nova/api/openstack/compute/contrib/console_output.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nova/api/openstack/compute/contrib/console_output.py b/nova/api/openstack/compute/contrib/console_output.py index 1eb86a092..3c3a597c6 100644 --- a/nova/api/openstack/compute/contrib/console_output.py +++ b/nova/api/openstack/compute/contrib/console_output.py @@ -16,6 +16,7 @@ # License for the specific language governing permissions and limitations # under the License +import re import webob from nova import compute @@ -57,6 +58,10 @@ class ConsoleOutputController(wsgi.Controller): except exception.NotFound: raise webob.exc.HTTPNotFound(_('Instance not found')) + # XML output is not correctly escaped, so remove invalid characters + remove_re = re.compile('[\x00-\x08\x0B-\x0C\x0E-\x1F]') + output = remove_re.sub('', output) + return {'output': output} -- cgit