diff --git a/libs/gst/check/libcheck/check_print.c b/libs/gst/check/libcheck/check_print.c index f170d60ee6..e29aa7b0f1 100644 --- a/libs/gst/check/libcheck/check_print.c +++ b/libs/gst/check/libcheck/check_print.c @@ -106,6 +106,38 @@ tr_fprint (FILE * file, TestResult * tr, enum print_output print_mode) } } +static void +fprint_xml_esc (FILE * file, const char *str) +{ + for (; *str != '\0'; str++) { + + switch (*str) { + + /* handle special characters that must be escaped */ + case '"': + fputs (""", file); + break; + case '\'': + fputs ("'", file); + break; + case '<': + fputs ("<", file); + break; + case '>': + fputs (">", file); + break; + case '&': + fputs ("&", file); + break; + + /* regular characters, print as is */ + default: + fputc (*str, file); + break; + } + } +} + void tr_xmlprint (FILE * file, TestResult * tr, enum print_output print_mode CK_ATTRIBUTE_UNUSED) @@ -147,8 +179,12 @@ tr_xmlprint (FILE * file, TestResult * tr, fprintf (file, " %s:%d\n", file_name, tr->line); fprintf (file, " %s\n", tr->tname); fprintf (file, " %d\n", tr->iter); - fprintf (file, " %s\n", tr->tcname); - fprintf (file, " %s\n", tr->msg); + fprintf (file, " "); + fprint_xml_esc (file, tr->tcname); + fprintf (file, "\n"); + fprintf (file, " "); + fprint_xml_esc (file, tr->msg); + fprintf (file, "\n"); fprintf (file, " \n"); if (slash != NULL) {