TOPdesk / dart-junitreport

An application to generate JUnit XML reports from dart test runs.
https://pub.dartlang.org/packages/junitreport
MIT License
31 stars 45 forks source link

System output with Terminal control codes such as U+001B causes error when parting XML #36

Open ihancock opened 2 years ago

ihancock commented 2 years ago

Our application uses Logger package which color codes log output. This introduces Unicode character code in the XML output which are not encoded into and XML entity.

See attached log file

ihancock commented 2 years ago

log.txt

rspilker commented 2 years ago

What version are you using? A recent version should have fixed some illegal Unicode in XML problems.

ihancock commented 2 years ago

The version is 2.0.2 which I believe is the latest.

dinwath commented 2 years ago

I believe that the problem arises because control characters are invalid in XML 1.0 but allowed in XML 1.1, see this wiki page and also this stackoverflow question

opened PR #39

lazytesting commented 2 years ago

I just ran into this as well as the azure devops report task is not willing to eat invalid xml, would be great if the PR of @dinwath could be merged

lazytesting commented 2 years ago

for reference: I quickly tested if moving the xml version to 1.1 would fix the issue I had in azure devops. Unfortunately it is not, seems that they do only support xml version 1.0. Not sure if that is something specifically on their end or something in the junit format.

petrnymsa commented 2 years ago

for reference: I quickly tested if moving the xml version to 1.1 would fix the issue I had in azure devops. Unfortunately it is not, seems that they do only support xml version 1.0. Not sure if that is something specifically on their end or something in the junit format.

@lazytesting Experiencing same issue with Azure devops, were you able solve it?

I've tried to "clean up" outputted XML file with some regex magic like

sed -Er -i'.bak' 's,\[34m|\[90m|\[31m|\[31m|\[0m|-\]|\[-,,g' TEST-report.xml

Basically, remove any escape characters, but they are apparently not all. So looking for some better solution.

lazytesting commented 1 year ago

For us it was only 1 character which gave the problem and this task solved it:

 - task: Bash@3
      displayName: "Fix test report"
      condition: always()
      inputs:
        targetType: 'inline'
        script: "sed 's/[]//g' -i test-report.xml"