Commit 527b3ed3 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Fixed escaping of special XML/HTML chars in CTestXML2HTML.

parent bafd02ff
...@@ -2,6 +2,9 @@ package GaudiPolicy ...@@ -2,6 +2,9 @@ package GaudiPolicy
package manager: Marco Clemencic package manager: Marco Clemencic
Commit Id: $Format:%H$ Commit Id: $Format:%H$
! 2015-03-04 - Marco Clemencic
- Fixed escaping of special XML/HTML chars in CTestXML2HTML.
! 2015-02-21 - Marco Clemencic ! 2015-02-21 - Marco Clemencic
- Fixed issue in run_qmtest when called from CMT. - Fixed issue in run_qmtest when called from CMT.
(it should have been fixed already, but the fix disappeared in the merge) (it should have been fixed already, but the fix disappeared in the merge)
......
...@@ -6,7 +6,6 @@ import re ...@@ -6,7 +6,6 @@ import re
import shutil import shutil
import bisect import bisect
import time import time
import codecs
from datetime import datetime,timedelta from datetime import datetime,timedelta
from optparse import OptionParser from optparse import OptionParser
...@@ -50,6 +49,15 @@ def cleanXml(xmlFileName): ...@@ -50,6 +49,15 @@ def cleanXml(xmlFileName):
xmlFile.write(_illegal_xml_chars_Re.sub("", data)) xmlFile.write(_illegal_xml_chars_Re.sub("", data))
xmlFile.close() xmlFile.close()
def formatMeasurementText(txt):
'''
Helper to correctly convert plain text to valid HTML (in a <pre> tag).
'''
from xml.sax.saxutils import escape
from codecs import encode
return '<pre>{0}</pre>'.format(escape(encode(txt, 'utf-8',
'xmlcharrefreplace')))
## Some regular expression that is going to be used in the next functions ## Some regular expression that is going to be used in the next functions
space_Re = re.compile(r"[ ]") space_Re = re.compile(r"[ ]")
illegal_web_chars_Re = re.compile(r"[<>,\'\"#]") illegal_web_chars_Re = re.compile(r"[<>,\'\"#]")
...@@ -629,13 +637,10 @@ def main(): ...@@ -629,13 +637,10 @@ def main():
# write the stdout # write the stdout
if Results.find("Measurement") is not None : if Results.find("Measurement") is not None :
value = Results.find("Measurement").find("Value") value = Results.find("Measurement").find("Value")
stdout = open(os.path.join(testCaseDir,"stdout"),"w") stdout = open(os.path.join(testCaseDir, "stdout"), "w")
if value is not None and value.text is not None : if value is not None and value.text is not None :
stdout.write("<pre>" + stdout.write(formatMeasurementText(value.text))
codecs.encode(value.text, 'utf-8', else:
'xmlcharrefreplace') +
"</pre>")
else :
stdout.write("<pre></pre>") stdout.write("<pre></pre>")
stdout.close() stdout.close()
else : else :
...@@ -652,10 +657,7 @@ def main(): ...@@ -652,10 +657,7 @@ def main():
# Consider the void measurment # Consider the void measurment
if value is not None and value.text is not None : if value is not None and value.text is not None :
NamedMeasurementFile.write("<pre>" + NamedMeasurementFile.write(formatMeasurementText(value.text))
codecs.encode(value.text, 'utf-8',
'xmlcharrefreplace') +
"</pre>")
else : else :
NamedMeasurementFile.write("<pre></pre>") NamedMeasurementFile.write("<pre></pre>")
NamedMeasurementFile.close() NamedMeasurementFile.close()
...@@ -670,10 +672,7 @@ def main(): ...@@ -670,10 +672,7 @@ def main():
# Consider the void measurment # Consider the void measurment
if value is not None and value.text is not None : if value is not None and value.text is not None :
NamedMeasurementFile.write("<pre>" + NamedMeasurementFile.write(formatMeasurementText(value.text))
codecs.encode(value.text, 'utf-8',
'xmlcharrefreplace') +
"</pre>")
else : else :
NamedMeasurementFile.write("<pre></pre>") NamedMeasurementFile.write("<pre></pre>")
NamedMeasurementFile.close() NamedMeasurementFile.close()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment