From 3bd1a62fe3abac36878172e75324f2fe8b4da4b1 Mon Sep 17 00:00:00 2001 From: Dennis Brandenburg Date: Tue, 17 Feb 2015 10:23:15 +0100 Subject: [PATCH] Escaping tags individually for building the describe_tags template to support get_all_tags --- moto/ec2/responses/tags.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/moto/ec2/responses/tags.py b/moto/ec2/responses/tags.py index a46690bef..0e01e13bc 100644 --- a/moto/ec2/responses/tags.py +++ b/moto/ec2/responses/tags.py @@ -1,7 +1,10 @@ from __future__ import unicode_literals +from jinja2 import Template + from moto.core.responses import BaseResponse from moto.ec2.models import validate_resource_ids from moto.ec2.utils import sequence_from_querystring, tags_from_query_string, filters_from_querystring +from xml.sax.saxutils import escape class TagResponse(BaseResponse): @@ -24,7 +27,9 @@ class TagResponse(BaseResponse): def describe_tags(self): filters = filters_from_querystring(querystring_dict=self.querystring) tags = self.ec2_backend.describe_tags(filters=filters) - template = self.response_template(DESCRIBE_RESPONSE) + for tag in tags: + tag['value'] = escape(tag['value']) + template = Template(DESCRIBE_RESPONSE) return template.render(tags=tags)