You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Todor Todorov (JIRA)" <ji...@codehaus.org> on 2013/07/12 15:48:05 UTC

[jira] (SUREFIRE-996) and content of junit xml report are not escaped

     [ https://jira.codehaus.org/browse/SUREFIRE-996?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Todor Todorov updated SUREFIRE-996:
-----------------------------------

    Attachment: extended-test-case-for-SUREFIRE-996.patch

<system-out> and <system-err> content is still wrong. The illegal characters handling from SUREFIRE-456 doesn't work since version 2.15 and generates illegal XML file. The problem is that the illegal character is not converted to its string representation (e.g. 0 -> "0") before OutputStream#write invocation.

This patch extends the test case including illegal characters in system-out and system-err content. It also includes possible fix for this issue.
                
> <system-out> and <system-err> content of junit xml report are not escaped
> -------------------------------------------------------------------------
>
>                 Key: SUREFIRE-996
>                 URL: https://jira.codehaus.org/browse/SUREFIRE-996
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Junit 4.7+ (parallel) support
>    Affects Versions: 2.15
>         Environment: maven 3.0.4
> surefire 2.15-SNAPSHOT (from apache snashot repo)
>            Reporter: Julien Vermillard
>            Assignee: Kristian Rosenvold
>            Priority: Blocker
>             Fix For: 2.15
>
>         Attachments: 0001-added-test-case-for-SUREFIRE-996.patch, extended-test-case-for-SUREFIRE-996.patch
>
>
> Some of my junit xml report are not correctly generated :
> {code}
> <system-out>15:24:59.565 [pool-1-thread-5] INFO  c.s.a.i.c.s.api.PartnerServicesUtils - Profile <null> 
> </system-out>
> {code}
> The < and > in "<null>" are not escaped.
> If I look at maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
> code, I think the bug is here :
> {code}
>         addOutputStreamElement( outputStreamWriter, fw, eos, ppw, report.getStdout(), "system-out" );
>         addOutputStreamElement( outputStreamWriter, fw, eos, ppw, report.getStdErr(), "system-err" );
>         ppw.endElement(); // test element
>     }
>     private void addOutputStreamElement( OutputStreamWriter outputStreamWriter, OutputStream fw, EncodingOutputStream eos, XMLWriter xmlWriter, DeferredFileOutputStream stdOut,
>                                          String name )
>     {
>         if ( stdOut != null && stdOut.getByteCount() > 0 )
>         {
>             xmlWriter.startElement( name );
>             try
>             {
>                 xmlWriter.writeText( "" ); // Cheat sax to emit element
>                 outputStreamWriter.flush();
>                 stdOut.close();
>                 stdOut.writeTo( eos );
>                 eos.flush();
>             }
>             catch ( IOException e )
>             {
>                 throw new ReporterException( "When writing xml report stdout/stderr", e );
>             }
>             xmlWriter.endElement();
>         }
>     }
> {code}
> and probably introduced by this commit : 
> commit 33e110fc46aa43d10b38a93b3db74c09be6bc6d5
> Author: Kristian Rosenvold <kr...@apache.org>
> Date:   Thu May 2 20:53:27 2013 +0200
>     [SUREFIRE-938] Removed memory binding for stdout/stderr capture.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira