Add ability for specific backends to enable template escaping. Closes #441.

This commit is contained in:
Steve Pulec 2015-11-03 09:25:47 -05:00
commit d3e4c2c4b5
6 changed files with 27 additions and 6 deletions

View file

@ -66,3 +66,7 @@ class EC2Response(
def ec2_backend(self):
from moto.ec2.models import ec2_backends
return ec2_backends[self.region]
@property
def should_autoescape(self):
return True

View file

@ -1,6 +1,5 @@
from __future__ import unicode_literals
from xml.sax.saxutils import escape
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
@ -26,8 +25,6 @@ class TagResponse(BaseResponse):
def describe_tags(self):
filters = filters_from_querystring(querystring_dict=self.querystring)
tags = self.ec2_backend.describe_tags(filters=filters)
for tag in tags:
tag['value'] = escape(tag['value'])
template = self.response_template(DESCRIBE_RESPONSE)
return template.render(tags=tags)