]> source.dussan.org Git - gitblit.git/commitdiff
Fix #1114 HttpUtils getGitblitURL does not support nonstandard ports 1201/head
authorJan Breuer <jan.breuer@mobatime.cz>
Wed, 15 Feb 2017 17:58:55 +0000 (18:58 +0100)
committerJan Breuer <jan.breuer@mobatime.cz>
Wed, 15 Feb 2017 17:58:55 +0000 (18:58 +0100)
X-Forwarded-Host can contain port number and it is added twice in that situation
This fix just prevent adding port number if it is already there

src/main/java/com/gitblit/utils/HttpUtils.java

index 2fd8d898ef9412a9fb17cefc4d5599e3824c50b7..27df5a52c125be44af92d50a58b20a7d563ba45a 100644 (file)
@@ -110,7 +110,9 @@ public class HttpUtils {
                sb.append(host);\r
                if (("http".equals(scheme) && port != 80)\r
                                || ("https".equals(scheme) && port != 443)) {\r
-                       sb.append(":").append(port);\r
+                       if (!host.endsWith(":" + port)) {\r
+                               sb.append(":").append(port);\r
+                       }\r
                }\r
                sb.append(context);\r
                return sb.toString();\r