ODFDoc : issue 3187 : <, > and & should be escaped

svn: r13118
This commit is contained in:
Serge Noiraud 2009-08-25 16:48:12 +00:00
parent f1352ee2ee
commit 442eaf9923

View File

@ -1216,6 +1216,9 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
"""
text = str(styledtext)
s_tags = styledtext.get_tags()
text = text.replace('&', '\1') # must be the first
text = text.replace('<', '\2')
text = text.replace('>', '\3')
markuptext = self._backend.add_markup_from_styled(text, s_tags)
# we need to know if we have new styles to add.
# if markuptext contains : FontColor, FontFace, FontSize ...
@ -1234,6 +1237,9 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
start = m.end()
linenb = 1
self.start_paragraph(style_name)
markuptext = markuptext.replace('\1', '&amp;') # must be the first
markuptext = markuptext.replace('\2', '&lt;')
markuptext = markuptext.replace('\3', '&gt;')
for line in markuptext.split('\n'):
if ( linenb > 1 ):
self.cntnt.write('<text:line-break/>')