Fix wrong regexp used to unscape xml entities inside jinja tags.
This commit is contained in:
parent
0f6c0eb172
commit
ea2cc534a2
1 changed files with 7 additions and 7 deletions
14
secretary.py
14
secretary.py
|
|
@ -26,7 +26,7 @@ from os import path
|
||||||
from mimetypes import guess_type, guess_extension
|
from mimetypes import guess_type, guess_extension
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from xml.dom.minidom import parseString
|
from xml.dom.minidom import parseString
|
||||||
from xml.parsers.expat import ExpatError
|
from xml.parsers.expat import ExpatError, ErrorString
|
||||||
from jinja2 import Environment, Undefined
|
from jinja2 import Environment, Undefined
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -308,10 +308,10 @@ class Renderer(object):
|
||||||
"""
|
"""
|
||||||
unescape_rules = {
|
unescape_rules = {
|
||||||
r'(?is)({([{|%])[^%|}]*?)(</?text:s.*?>)(.*?[%|}]})': r'\1 \4',
|
r'(?is)({([{|%])[^%|}]*?)(</?text:s.*?>)(.*?[%|}]})': r'\1 \4',
|
||||||
r'(?is)({([{|%]).*)(>)(.*?[%|}]})' : r'\1>\4',
|
r'(?is)({([{|%])[^%|}]*?)(>)(.*?[%|}]})' : r'\1>\4',
|
||||||
r'(?is)({([{|%]).*)(<)(.*?[%|}]})' : r'\1<\4',
|
r'(?is)({([{|%])[^%|}]*?)(<)(.*?[%|}]})' : r'\1<\4',
|
||||||
r'(?is)({([{|%]).*)(&)(.*?[%|}]})' : r'\1&\4',
|
r'(?is)({([{|%])[^%|}]*?)(&)(.*?[%|}]})' : r'\1&\4',
|
||||||
r'(?is)({([{|%]).*)(")(.*?[%|}]})' : r'\1"\4',
|
r'(?is)({([{|%])[^%|}]*?)(")(.*?[%|}]})' : r'\1"\4',
|
||||||
}
|
}
|
||||||
|
|
||||||
for regexp, replacement in unescape_rules.items():
|
for regexp, replacement in unescape_rules.items():
|
||||||
|
|
@ -457,8 +457,8 @@ class Renderer(object):
|
||||||
return final_xml
|
return final_xml
|
||||||
except ExpatError as e:
|
except ExpatError as e:
|
||||||
near = result.split('\n')[e.lineno -1][e.offset-50:e.offset+50]
|
near = result.split('\n')[e.lineno -1][e.offset-50:e.offset+50]
|
||||||
raise ExpatError('ExpatError at line %d, column %d\nNear of: "[...]%s[...]"' % \
|
raise ExpatError('ExpatError "%s" at line %d, column %d\nNear of: "[...]%s[...]"' % \
|
||||||
(e.lineno, e.offset, near))
|
(ErrorString(e.code), e.lineno, e.offset, near))
|
||||||
except:
|
except:
|
||||||
self.log.error('Error rendering template:\n%s',
|
self.log.error('Error rendering template:\n%s',
|
||||||
xml_document.toprettyxml(), exc_info=True)
|
xml_document.toprettyxml(), exc_info=True)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue