doortts doortts 2017-09-25
mail: Fix wrong urlencoded 'Reply To' address
Yona provides a function to register an issue or comment
through reply to mail. It is called Mailbox service.

Reply to mail address could contains slash.
e.g. yona+yona-projects/yona/issue_post/391

Normal urlencoding for that could have a problem
because slash for path is also urlencoded.

e.g. yona+yona-project%2Fyona%2Fissue_post%2f391

This commit will fix that.

See: Yona Github issue #300
@e3e0659a416985427e7ee77bda8ef8a39b198363
app/models/NotificationMail.java
--- app/models/NotificationMail.java
+++ app/models/NotificationMail.java
@@ -600,7 +600,7 @@
         if (detail != null) {
             EmailAddressWithDetail addr =
                     new EmailAddressWithDetail(Config.getEmailFromImap());
-            addr.setDetail(HttpUtil.encodeUrlString(detail));
+            addr.setDetail(HttpUtil.getEncodeEachPathName(detail));
             return addr.toString();
         } else {
             return null;
app/utils/HttpUtil.java
--- app/utils/HttpUtil.java
+++ app/utils/HttpUtil.java
@@ -220,7 +220,13 @@
     }
 
     // It is made for path which contains UTF8 chars
-    public static String getEncodeEachPathName(String path){
+    public static String getEncodeEachPathName(String path) {
+        if (StringUtils.isBlank(path)) {
+            return path;
+        }
+        if (!path.contains("/")) {
+            return HttpUtil.encodeUrlString(path);
+        }
         String[] paths = path.split("/");
         String[] encodedPaths = new String[paths.length];
         for ( int i = 0; i < paths.length; i++ ) {
Add a comment
List