From: Darrick J. Wong <djwong@xxxxxxxxxx> The XML report format captures the contents of .full and .out.bad files in CDATA sections. CDATA sections are supposed to be a stream of verbatim data, terminated with a "]]>". Hence XML entities such as quotation marks and angle brackes should not be escaped, and an actual bracket-bracket-gt sequence in those files /does/ need escaping. Create a separate filtering function so that these files are encoded properly. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- common/report | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/report b/common/report index be991b55f5..eb169175bc 100644 --- a/common/report +++ b/common/report @@ -19,6 +19,11 @@ encode_xml() -e 's/"/\"/g' } +encode_cdata() +{ + cat -v | sed -e 's/]]>/]]]]><![CDATA[>/g' +} + # # Xunit format report functions _xunit_add_property() @@ -128,7 +133,7 @@ _xunit_make_testcase_report() if [ -z "$quiet" -a -s "$full_file" ]; then echo -e "\t\t<system-out>" >> $report printf '<![CDATA[\n' >>$report - cat "$full_file" | tr -dc '[:print:][:space:]' | encode_xml >>$report + cat "$full_file" | tr -dc '[:print:][:space:]' | encode_cdata >>$report printf ']]>\n' >>$report echo -e "\t\t</system-out>" >> $report fi @@ -137,13 +142,13 @@ _xunit_make_testcase_report() elif [ -f "$dmesg_file" ]; then echo -e "\t\t<system-err>" >> $report printf '<![CDATA[\n' >>$report - cat "$dmesg_file" | tr -dc '[:print:][:space:]' | encode_xml >>$report + cat "$dmesg_file" | tr -dc '[:print:][:space:]' | encode_cdata >>$report printf ']]>\n' >>$report echo -e "\t\t</system-err>" >> $report elif [ -s "$outbad_file" ]; then echo -e "\t\t<system-err>" >> $report printf '<![CDATA[\n' >>$report - $diff "$out_src" "$outbad_file" | encode_xml >>$report + $diff "$out_src" "$outbad_file" | encode_cdata >>$report printf ']]>\n' >>$report echo -e "\t\t</system-err>" >> $report fi