-
Notifications
You must be signed in to change notification settings - Fork 440
Closed
Description
If outputting text with ANSI controls, the Junit formatter will create invalid XML. For instance:
@test "my-test" {
printf "\e[1mhello\e[0m"
return 1
}
Produces this output (with properties redacted)
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="my_test.bats" tests="1" failures="1" errors="0" skipped="0" time="0" timestamp="2020-05-12T15:01:25">
<testcase classname="my_test.bats" name="my-test" time="0">
<failure type="failure"><![CDATA[
(in test file test/my_test.bats, line 106)
`printf "\e[1mhello\e[0m"' failed
�[1mhello�[0m]]></failure>
</testcase>
<system-out></system-out>
<system-err></system-err>
</testsuite>
The CDATA section includes the control character literal �
(Unicode: 0x1b), which are invalid XML characters. This is causing some XML parsers to fail parsing the resulting file.
I think maybe there's two ways to handle this:
- Encode the escape character (as
\e
or\033
or something) - Strip all control characters from the captured output
Metadata
Metadata
Assignees
Labels
No labels