mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
libcheck: Escape strings in the generated xml files
This is copy pasted from upstream libcheck
This commit is contained in:
parent
0a41beaa56
commit
259e7c30a0
1 changed files with 38 additions and 2 deletions
|
@ -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
|
void
|
||||||
tr_xmlprint (FILE * file, TestResult * tr,
|
tr_xmlprint (FILE * file, TestResult * tr,
|
||||||
enum print_output print_mode CK_ATTRIBUTE_UNUSED)
|
enum print_output print_mode CK_ATTRIBUTE_UNUSED)
|
||||||
|
@ -147,8 +179,12 @@ tr_xmlprint (FILE * file, TestResult * tr,
|
||||||
fprintf (file, " <fn>%s:%d</fn>\n", file_name, tr->line);
|
fprintf (file, " <fn>%s:%d</fn>\n", file_name, tr->line);
|
||||||
fprintf (file, " <id>%s</id>\n", tr->tname);
|
fprintf (file, " <id>%s</id>\n", tr->tname);
|
||||||
fprintf (file, " <iteration>%d</iteration>\n", tr->iter);
|
fprintf (file, " <iteration>%d</iteration>\n", tr->iter);
|
||||||
fprintf (file, " <description>%s</description>\n", tr->tcname);
|
fprintf (file, " <description>");
|
||||||
fprintf (file, " <message>%s</message>\n", tr->msg);
|
fprint_xml_esc (file, tr->tcname);
|
||||||
|
fprintf (file, "</description>\n");
|
||||||
|
fprintf (file, " <message>");
|
||||||
|
fprint_xml_esc (file, tr->msg);
|
||||||
|
fprintf (file, "</message>\n");
|
||||||
fprintf (file, " </test>\n");
|
fprintf (file, " </test>\n");
|
||||||
|
|
||||||
if (slash != NULL) {
|
if (slash != NULL) {
|
||||||
|
|
Loading…
Reference in a new issue