Skip to contentSkip to conversation

report: make sure control charcters are encoded in xUnit report

PATCH New Theodore Ts'o 1 participant 1 message May 19, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 common/report | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
common/report +6 -5
index ffa23719..a62d343e 100644
@@ -27,11 +27,12 @@ REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_WORK"
 
 encode_xml()
 {
-    sed -e 's/&/\&/g' \
-	-e 's/>/\>/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'
 }
 
 #
Signature · 1 line
2.16.1.72.g5be1f00a9a