Skip to content

Commit 5d7f68f

Browse files
committed
CDRIVER-1999 escape raw log in test-results.json
1 parent 8aed182 commit 5d7f68f

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

tests/TestSuite.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -555,21 +555,9 @@ TestSuite_RunFuncInChild (TestSuite *suite, /* IN */
555555
static void
556556
_append_json_escaped (bson_string_t *buf, const char *s)
557557
{
558-
while (*s) {
559-
if (*s == '"') {
560-
bson_string_append_c (buf, '\\');
561-
bson_string_append_c (buf, '\"');
562-
} else if (*s == '\n') {
563-
bson_string_append_c (buf, '\\');
564-
bson_string_append_c (buf, 'n');
565-
} else if (*s == '\t') {
566-
bson_string_append (buf, " ");
567-
} else {
568-
bson_string_append_c (buf, *s);
569-
}
570-
571-
s++;
572-
}
558+
char *escaped = bson_utf8_escape_for_json (s, -1);
559+
bson_string_append (buf, escaped);
560+
bson_free (escaped);
573561
}
574562

575563

0 commit comments

Comments
 (0)