Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-996

<system-out> and <system-err> content of junit xml report are not escaped

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 2.15
    • 2.15
    • None
    • maven 3.0.4
      surefire 2.15-SNAPSHOT (from apache snashot repo)

    Description

      Some of my junit xml report are not correctly generated :

      <system-out>15:24:59.565 [pool-1-thread-5] INFO  c.s.a.i.c.s.api.PartnerServicesUtils - Profile <null> 
      </system-out>
      

      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 :

              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();
              }
          }
      
      
      

      and probably introduced by this commit :
      commit 33e110fc46aa43d10b38a93b3db74c09be6bc6d5
      Author: Kristian Rosenvold <krosenvold@apache.org>
      Date: Thu May 2 20:53:27 2013 +0200

      SUREFIRE-938 Removed memory binding for stdout/stderr capture.

      Attachments

        Issue Links

          Activity

            People

              krosenvold Kristian Rosenvold
              vrm Julien Vermillard
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: