]> source.dussan.org Git - gitblit.git/commitdiff
Improve username (en|de)coding for urls
authorJames Moger <james.moger@gitblit.com>
Thu, 20 Jun 2013 21:29:05 +0000 (17:29 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 20 Jun 2013 21:29:05 +0000 (17:29 -0400)
src/main/java/com/gitblit/GitBlit.java

index 3aaa8c6de5a4b1a19f0654ccc99bed50dee07b09..c6e24d77eae2742e603ffeaa8aa6fee063231acc 100644 (file)
@@ -967,12 +967,24 @@ public class GitBlit implements ServletContextListener {
                userService.logout(user);
        }
 
+       /**
+        * Encode the username for user in an url.
+        * 
+        * @param name
+        * @return the encoded name
+        */
        protected String encodeUsername(String name) {
-               return name.replace("@", "%40")       
+               return name.replace("@", "%40").replace(" ", "%20").replace("\\", "%5C");       
        }
 
+       /**
+        * Decode a username from an encoded url.
+        * 
+        * @param name
+        * @return the decoded name
+        */
        protected String decodeUsername(String name) {
-               return name.replace("%40", "@");        
+               return name.replace("%40", "@").replace("%20", " ").replace("%5C", "\\");
        }
        
        /**