New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
phpunit --log-junit generates invalid xml file when test output contains binary data #2974
Comments
This is the code we've been using in drupalci to defend our xml against invalid chars: |
A pull request would be appreciated. |
mkasberg
added a commit
to mkasberg/phpunit
that referenced
this issue
Feb 16, 2018
JUnit XML (produced with --log-junit) is invalid (and won't be opened by some programs) if it contains invalid XML characters in the <system-out> node. Fix this by sanitizing text before adding it to the XML.
I was able to reproduce it and found a simple fix for the problem. This test case should help if you're trying to reproduce: BadJunitXMLTest.php
|
sebastianbergmann
pushed a commit
that referenced
this issue
Feb 16, 2018
JUnit XML (produced with --log-junit) is invalid (and won't be opened by some programs) if it contains invalid XML characters in the <system-out> node. Fix this by sanitizing text before adding it to the XML.
SimonHeimberg
added a commit
to SimonHeimberg/php-censor
that referenced
this issue
Feb 27, 2018
Work around outup from phpunit versions before 6.5.7/7.0.2 (before sebastianbergmann/phpunit#2974 was fixed).
corpsee
pushed a commit
to php-censor/php-censor
that referenced
this issue
May 1, 2018
Work around outup from phpunit versions before 6.5.7/7.0.2 (before sebastianbergmann/phpunit#2974 was fixed).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
running phpunit --log-junit
/some/file_junit.xml
generates an invalid xml file when a test produces output with binary data.shortened example output:
The illegal characters are after
<system-out>PK
, this element reads as<system-out>PK\x03\x04\x14</system-out>
(\xNN is hex encoded).As file do download: illegal_xml_from_phpunit_junit.xml.txt
Notes
about allowed characters in xml: https://stackoverflow.com/a/28152666/4124767
I do not know what replacements does the xml writer of php (hopefully & and > and similar).
Somewhere (on stackoverflow?) I found the following code to replace illegal characters. I do not yet an Idea if this helps.
The text was updated successfully, but these errors were encountered: