Fixes #6227 skip non-unicode strings and catch decode errors silently in template_from_string

This commit is contained in:
James Tanner 2014-03-17 16:54:25 -04:00
parent 8eb547edaa
commit ad70e9bcd6

View file

@ -310,7 +310,13 @@ def template_from_string(basedir, data, vars, fail_on_undefined=False):
if os.path.exists(filesdir):
basedir = filesdir
data = data.decode('utf-8')
# 6227
if isinstance(data, unicode):
try:
data = data.decode('utf-8')
except UnicodeEncodeError, e:
pass
try:
t = environment.from_string(data)
except Exception, e: