# Mount URL parameters\r
# This setting controls if pretty or parameter URLs are used.\r
# i.e.\r
-# if true: http://localhost/commit/myrepo/abcdef\r
-# if false: http://localhost/commit/?r=myrepo&h=abcdef\r
+# if true:\r
+# http://localhost/commit/myrepo/abcdef\r
+# if false:\r
+# http://localhost/commit/?r=myrepo&h=abcdef\r
#\r
# SINCE 0.5.0\r
# RESTART REQUIRED\r
web.mountParameters = true\r
\r
+# Some servlet containers (e.g. Tomcat >= 6.0.10) disallow '/' (%2F) encoding\r
+# in URLs as a security precaution for proxies. This setting tells Gitblit\r
+# to preemptively replace '/' with '*' or '!' for url string parameters.\r
+#\r
+# <https://issues.apache.org/jira/browse/WICKET-1303>\r
+# <http://tomcat.apache.org/security-6.html>\r
+#\r
+# SINCE 0.5.2\r
+web.forwardSlashCharacter = /\r
+\r
# Show other URLs on the summary page for accessing your git repositories\r
# Use spaces to separate urls. {0} is the token for the repository name.\r
# e.g.\r
\r
**%VERSION%** ([go](http://code.google.com/p/gitblit/downloads/detail?name=%GO%)|[war](http://code.google.com/p/gitblit/downloads/detail?name=%WAR%)) based on [%JGIT%][jgit] *released %BUILDDATE%*\r
\r
+- forward-slashes ('/', %2F) can be encoded using a custom character to workaround some servlet container default security measures for proxy servers<br/>**New:** *web.forwardSlashCharacter = /*\r
- optionally display repository on-disk size on repositories page<br/>**New:** *web.showRepositorySizes = true*\r
- tone-down repository group header color\r
\r
### Gitblit WAR will not authenticate any users?!\r
Confirm that the <context-param> *realm.userService* value in your `web.xml` file actually points to a `users.properties` file.\r
\r
+### Gitblit won't open my grouped repository (/group/myrepo.git) or browse my branch/tag/ref?!\r
+This is likely an url encoding/decoding problem. In `gitblit.properties` or `web.xml`, try setting *web.mountParameters* to *false*.\r
+\r
## General Interest Questions\r
\r
### Gitblit? What kind of name is that?\r
### Current Release\r
**%VERSION%** ([go](http://code.google.com/p/gitblit/downloads/detail?name=%GO%)|[war](http://code.google.com/p/gitblit/downloads/detail?name=%WAR%)) based on [%JGIT%][jgit] *released %BUILDDATE%*\r
\r
+- forward-slashes ('/', %2F) can be encoded using a custom character to workaround some servlet container default security measures for proxy servers<br/>**New:** *web.forwardSlashCharacter = /*\r
- optionally display repository on-disk size on repositories page<br/>**New:** *web.showRepositorySizes = true*\r
- tone-down repository group header color\r
\r
return self().settings.getInteger(key, defaultValue);\r
}\r
\r
+ /**\r
+ * Returns the char value for the specified key. If the key does not exist\r
+ * or the value for the key can not be interpreted as a character, the\r
+ * defaultValue is returned.\r
+ * \r
+ * @see IStoredSettings.getChar(String key, char defaultValue)\r
+ * @param key\r
+ * @param defaultValue\r
+ * @return key value or defaultValue\r
+ */\r
+ public static char getChar(String key, char defaultValue) {\r
+ return self().settings.getChar(key, defaultValue);\r
+ }\r
+ \r
/**\r
* Returns the string value for the specified key. If the key does not exist\r
* or the value for the key can not be interpreted as a string, the\r
}\r
return defaultValue;\r
}\r
+ \r
+ /**\r
+ * Returns the char value for the specified key. If the key does not exist\r
+ * or the value for the key can not be interpreted as a char, the\r
+ * defaultValue is returned.\r
+ * \r
+ * @param key\r
+ * @param defaultValue\r
+ * @return key value or defaultValue\r
+ */\r
+ public char getChar(String name, char defaultValue) {\r
+ Properties props = getSettings();\r
+ if (props.containsKey(name)) {\r
+ String value = props.getProperty(name);\r
+ if (!StringUtils.isEmpty(value)) {\r
+ return value.charAt(0);\r
+ }\r
+ }\r
+ return defaultValue;\r
+ }\r
\r
/**\r
* Returns the string value for the specified key. If the key does not exist\r
if (!GitBlit.getBoolean(Keys.web.mountParameters, true)) {\r
parameters = new String[] {};\r
}\r
- mount(new MixedParamUrlCodingStrategy(location, clazz, parameters));\r
+ mount(new GitblitParamUrlCodingStrategy(location, clazz, parameters));\r
}\r
\r
@Override\r
--- /dev/null
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.wicket;\r
+\r
+import org.apache.wicket.Page;\r
+import org.apache.wicket.protocol.http.WicketURLDecoder;\r
+import org.apache.wicket.protocol.http.WicketURLEncoder;\r
+import org.apache.wicket.request.target.coding.MixedParamUrlCodingStrategy;\r
+\r
+import com.gitblit.GitBlit;\r
+import com.gitblit.Keys;\r
+\r
+/**\r
+ * Simple subclass of mixed parameter url coding strategy that works around the\r
+ * encoded forward-slash issue that is present in some servlet containers.\r
+ * \r
+ * https://issues.apache.org/jira/browse/WICKET-1303\r
+ * http://tomcat.apache.org/security-6.html\r
+ * \r
+ * @author James Moger\r
+ * \r
+ */\r
+public class GitblitParamUrlCodingStrategy extends MixedParamUrlCodingStrategy {\r
+\r
+ /**\r
+ * Construct.\r
+ * \r
+ * @param <C>\r
+ * @param mountPath\r
+ * mount path (not empty)\r
+ * @param bookmarkablePageClass\r
+ * class of mounted page (not null)\r
+ * @param parameterNames\r
+ * the parameter names (not null)\r
+ */\r
+ public <C extends Page> GitblitParamUrlCodingStrategy(String mountPath,\r
+ Class<C> bookmarkablePageClass, String[] parameterNames) {\r
+ super(mountPath, bookmarkablePageClass, parameterNames);\r
+ }\r
+\r
+ /**\r
+ * Url encodes a string that is mean for a URL path (e.g., between slashes)\r
+ * \r
+ * @param string\r
+ * string to be encoded\r
+ * @return encoded string\r
+ */\r
+ protected String urlEncodePathComponent(String string) {\r
+ char altChar = GitBlit.getChar(Keys.web.forwardSlashCharacter, '/');\r
+ if (altChar != '/') {\r
+ string = string.replace('/', altChar);\r
+ }\r
+ return super.urlEncodePathComponent(string);\r
+ }\r
+\r
+ /**\r
+ * Returns a decoded value of the given value (taken from a URL path\r
+ * section)\r
+ * \r
+ * @param value\r
+ * @return Decodes the value\r
+ */\r
+ protected String urlDecodePathComponent(String value) {\r
+ char altChar = GitBlit.getChar(Keys.web.forwardSlashCharacter, '/');\r
+ if (altChar != '/') {\r
+ value = value.replace(altChar, '/');\r
+ }\r
+ return super.urlDecodePathComponent(value);\r
+ }\r
+}
\ No newline at end of file