maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dfabul...@apache.org
Subject svn commit: r597701 - in /maven/surefire/trunk: surefire-api/src/main/java/org/apache/maven/surefire/report/ surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ surefire-integration-tests/src/test/resources/surefire-224-wellFormedXm...
Date Fri, 23 Nov 2007 16:51:24 GMT
Author: dfabulich
Date: Fri Nov 23 08:51:23 2007
New Revision: 597701

URL: http://svn.apache.org/viewvc?rev=597701&view=rev
Log:
[SUREFIRE-57] Escape XML control characters before adding them to XML output

Modified:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire224WellFormedXmlFailuresTest.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/pom.xml
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/src/test/java/TestSurefire3.java

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java?rev=597701&r1=597700&r2=597701&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
Fri Nov 23 08:51:23 2007
@@ -19,12 +19,6 @@
  * under the License.
  */
 
-import org.apache.maven.surefire.util.PrettyPrintXMLWriter;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-import org.codehaus.plexus.util.xml.Xpp3DomWriter;
-
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -40,6 +34,11 @@
 import java.util.Properties;
 import java.util.StringTokenizer;
 
+import org.apache.maven.surefire.util.PrettyPrintXMLWriter;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomWriter;
+
 
 /**
  * XML format reporter.
@@ -273,9 +272,25 @@
     private static String escapeAttribute( String attribute )
     {
         // Shouldn't Xpp3Dom do this itself?
-        String s = StringUtils.replace( attribute, "<", "&lt;" );
-        s = StringUtils.replace( s, ">", "&gt;" );
-        return s;
+        StringBuffer sb = new StringBuffer ( attribute.length() * 2 );
+        for (int i = 0; i < attribute.length(); i++ ) {
+            char c = attribute.charAt( i );
+            if ( c < 32 ) {
+                if ( c == '\n' || c == '\r' || c == '\t') {
+                    sb.append( c );
+                } else {
+                    sb.append( "&#" ).append( (int) c).append( ';' );
+                }
+            } else if ( c == '<') {
+                sb.append( "&lt;" );
+            } else if ( c == '>') {
+                sb.append( "&gt;" );
+            }
+            else {
+                sb.append( c );
+            }
+        }
+        return sb.toString();
 
     }
 

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire224WellFormedXmlFailuresTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire224WellFormedXmlFailuresTest.java?rev=597701&r1=597700&r2=597701&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire224WellFormedXmlFailuresTest.java
(original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire224WellFormedXmlFailuresTest.java
Fri Nov 23 08:51:23 2007
@@ -26,7 +26,7 @@
         // verifier.verifyErrorFreeLog();
         verifier.resetStreams();
         
-        HelperAssertions.assertTestSuiteResults( 3, 0, 3, 0, testDir );
+        HelperAssertions.assertTestSuiteResults( 4, 0, 4, 0, testDir );
         
     }
 }

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/pom.xml?rev=597701&r1=597700&r2=597701&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/pom.xml
(original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/pom.xml
Fri Nov 23 08:51:23 2007
@@ -43,7 +43,6 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.1</version>
         <configuration>
           <testFailureIgnore>true</testFailureIgnore>
         </configuration>

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/src/test/java/TestSurefire3.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/src/test/java/TestSurefire3.java?rev=597701&r1=597700&r2=597701&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/src/test/java/TestSurefire3.java
(original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-224-wellFormedXmlFailures/src/test/java/TestSurefire3.java
Fri Nov 23 08:51:23 2007
@@ -33,4 +33,9 @@
         fail( ">" );
     }
 
+    public void testU0000()
+    {
+        fail( "\u0000" );
+    }
+
 }



Mime
View raw message