[MCHANGELOG-133] ChangeLog: allow encoding of file paths for gitblit
Submitted by Johannes Utzig

git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1467630 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java b/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
index aead601..cb27756 100644
--- a/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
+++ b/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
@@ -59,6 +59,7 @@
 import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
+import java.net.URLEncoder;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -230,6 +231,14 @@
     protected boolean skip;
 
     /**
+     * Encodes slashes in file uri. Required for some repository browsers like gitblit
+     *
+     * @since 2.3
+     */
+    @Parameter( property = "encodeFileUri", defaultValue = "false")
+    protected boolean encodeFileUri;
+
+    /**
      * The Maven Project Object
      */
     @Component
@@ -1473,18 +1482,31 @@
         {
             if ( !linkFile.equals( scmUrl ) )
             {
+                String linkName = name;
+                if(encodeFileUri)
+                {
+                    try
+                    {
+                        linkName = URLEncoder.encode(linkName, "UTF-8");
+                    }
+                    catch (UnsupportedEncodingException e)
+                    {
+                        // UTF-8 is always supported
+                    }
+                }
+
                 // Use the given URL to create links to the files
 
                 if ( linkFile.indexOf( FILE_TOKEN ) > 0 )
                 {
-                    linkFile = linkFile.replaceAll( FILE_TOKEN, name );
+                    linkFile = linkFile.replaceAll( FILE_TOKEN, linkName );
                 }
                 else
                 {
                     // This is here so that we are backwards compatible with the
                     // format used before the special token was introduced
 
-                    linkFile = linkFile + name;
+                    linkFile = linkFile + linkName;
                 }
 
                 // Use the given URL to create links to the files