report: make sure control charcters are encoded in xUnit report

Control characters (such as backspace, used in progress reports by
mkfs.ext4, for example) can make Python's XML parsers choke, claiming
that it is an invalid XML document.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Theodore Ts'o
2018-05-19 13:43:10 -04:00
committed by Eryu Guan
parent 968ccf32e4
commit b13f51d571
+6 -5
View File
@@ -27,11 +27,12 @@ REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_WORK"
encode_xml()
{
sed -e 's/&/\&amp;/g' \
-e 's/>/\&gt;/g' \
-e 's/</\&lt;/g' \
-e "s/'/\&apos;/g" \
-e 's/"/\&quot;/g'
cat -v | \
sed -e 's/&/\&amp;/g' \
-e 's/>/\&gt;/g' \
-e 's/</\&lt;/g' \
-e "s/'/\&apos;/g" \
-e 's/"/\&quot;/g'
}
#