maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agud...@apache.org
Subject [2/2] git commit: SUREFIRE-1099 avoid invalid link ids
Date Sat, 27 Sep 2014 18:03:54 GMT
SUREFIRE-1099 avoid invalid link ids

Call toHtmlId() everytime before using testCase.getFullName() as anchor
id or link target.
Use DoxiaUtils.encodeId() in toHtmlId(), to avoid problems with any
illegal char.

This closes #36


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/a790a61a
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/a790a61a
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/a790a61a

Branch: refs/heads/master
Commit: a790a61acccb2da1524b64142ed180e30051841e
Parents: bad7cb9
Author: kermit-the-frog <github@martin.egge.info>
Authored: Thu Mar 13 09:42:17 2014 +0100
Committer: Andreas Gudian <agudian@apache.org>
Committed: Sat Sep 27 20:02:58 2014 +0200

----------------------------------------------------------------------
 .../surefire/report/SurefireReportGenerator.java    | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a790a61a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
----------------------------------------------------------------------
diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
index 944832a..68a83b2 100644
--- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
+++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java
@@ -31,6 +31,7 @@ import org.apache.maven.doxia.markup.HtmlMarkup;
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.SinkEventAttributeSet;
 import org.apache.maven.doxia.sink.SinkEventAttributes;
+import org.apache.maven.doxia.util.DoxiaUtils;
 import org.apache.maven.reporting.MavenReportException;
 
 /**
@@ -425,7 +426,7 @@ public class SurefireReportGenerator
 
                             if ( failure != null )
                             {
-                                sink.link( "#" + testCase.getFullName() );
+                                sink.link( "#" + toHtmlId( testCase.getFullName() ) );
 
                                 sinkIcon( (String) failure.get( "type" ), sink );
 
@@ -442,7 +443,7 @@ public class SurefireReportGenerator
                             {
                                 sink.tableCell();
 
-                                sinkLink( sink, testCase.getName(), "#" + testCase.getFullName()
);
+                                sinkLink( sink, testCase.getName(), "#" + toHtmlId( testCase.getFullName()
) );
 
                                 SinkEventAttributeSet atts = new SinkEventAttributeSet();
                                 atts.addAttribute( SinkEventAttributes.CLASS, "detailToggle"
);
@@ -540,7 +541,14 @@ public class SurefireReportGenerator
 
     private String toHtmlId( String id )
     {
-        return id.replace( ".", "_" );
+        if ( DoxiaUtils.isValidId(id) )
+        {
+            return id;
+        }
+        else
+        {
+            return DoxiaUtils.encodeId( id, true );
+        }
     }
 
     private void constructFailureDetails( Sink sink, ResourceBundle bundle, List<ReportTestCase>
failureList )
@@ -579,7 +587,7 @@ public class SurefireReportGenerator
 
                 sink.tableCell_();
 
-                sinkCellAnchor( sink, tCase.getName(), tCase.getFullName() );
+                sinkCellAnchor( sink, tCase.getName(), toHtmlId( tCase.getFullName() ) );
 
                 sink.tableRow_();
 


Mime
View raw message