diff mbox

report: make sure control charcters are encoded in xUnit report

Message ID 20180519174310.3511-1-tytso@mit.edu (mailing list archive)
State New, archived
Headers show

Commit Message

Theodore Ts'o May 19, 2018, 5:43 p.m. UTC
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>
---
 common/report | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/common/report b/common/report
index ffa23719..a62d343e 100644
--- a/common/report
+++ b/common/report
@@ -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'
 }
 
 #