maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r390296 - /maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
Date Fri, 31 Mar 2006 01:30:44 GMT
Author: brett
Date: Thu Mar 30 17:30:43 2006
New Revision: 390296

URL: http://svn.apache.org/viewcvs?rev=390296&view=rev
Log:
fix escaping of attributes containing < and >

Modified:
    maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/report/XMLReporter.java

Modified: maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/report/XMLReporter.java?rev=390296&r1=390295&r2=390296&view=diff
==============================================================================
--- maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
(original)
+++ maven/surefire/trunk/surefire/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
Thu Mar 30 17:30:43 2006
@@ -167,7 +167,7 @@
 
             if ( ( message != null ) && ( message.trim().length() > 0 ) )
             {
-                element.setAttribute( "message", message );
+                element.setAttribute( "message", escapeAttribute( message ));
 
                 element.setAttribute( "type", stackTrace.substring( 0, stackTrace.indexOf(
":" ) ) );
             }
@@ -258,10 +258,15 @@
 
                 property.setAttribute("name", key);
 
-                property.setAttribute("value", value);
+                property.setAttribute("value", escapeAttribute(value));
 
             }
         }
     }
     
+    private static String escapeAttribute( String attribute )
+    {
+        // Shouldn't Xpp3Dom do this itself?
+        return attribute.replaceAll( "<", "&lt;" ).replaceAll( ">", "&gt;"
);
+    }
 }



Mime
View raw message