2. *web.mountParameters = false* and use non-pretty, parameterized urls\r
3. *web.forwardSlashCharacter = !* which tells Gitblit to use **!** instead of **/**\r
\r
+#### UTF-8 Filenames\r
+\r
+Tomcat also dislikes urls with non-ASCII characters. If your repositories have non-ASCII filenames you will have to modify your connector properties to allow UTF-8 encoded urls. \r
+\r
+[Tomcat Character Encoding](http://wiki.apache.org/tomcat/FAQ/CharacterEncoding) \r
+[Tomcat Connector Properties](http://tomcat.apache.org/tomcat-6.0-doc/config/http.html)\r
+\r
## General Interest Questions\r
\r
### Gitblit? What kind of name is that?\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%) | [express](http://code.google.com/p/gitblit/downloads/detail?name=%EXPRESS%) | [fedclient](http://code.google.com/p/gitblit/downloads/detail?name=%FEDCLIENT%) | [manager](http://code.google.com/p/gitblit/downloads/detail?name=%MANAGER%) | [api](http://code.google.com/p/gitblit/downloads/detail?name=%API%)) based on [%JGIT%][jgit] *released %BUILDDATE%*\r
\r
+#### fixes\r
+\r
+- Fixed bug in the diff view for filenames that have non-ASCII characters (issue 128)\r
+\r
+#### additions\r
+\r
+- added RedmineUserService (github/mallowlabs)\r
+\r
#### changes\r
\r
- Emit a warning in the log file if running on a Tomcat-based servlet container which is unfriendly to %2F forward-slash url encoding AND Gitblit is configured to mount parameters with %2F forward-slash url encoding (Github/jpyeron, issue 126)\r
} else if (line.startsWith("---") || line.startsWith("+++")) {\r
// skip --- +++ lines\r
} else if (line.startsWith("diff")) {\r
+ line = StringUtils.convertOctal(line);\r
if (line.indexOf(oldnull) > -1) {\r
// a is null, use b\r
line = line.substring(("diff --git " + oldnull).length()).trim();\r
// trim b/\r
- line = line.substring(2);\r
+ line = line.substring(2).trim();\r
} else {\r
// use a\r
- line = line.substring("diff --git a/".length()).trim();\r
- line = line.substring(0, line.indexOf(" b/")).trim();\r
+ line = line.substring("diff --git ".length()).trim();\r
+ line = line.substring(line.startsWith("\"a/") ? 3 : 2); \r
+ line = line.substring(0, line.indexOf(" b/") > -1 ? line.indexOf(" b/") : line.indexOf("\"b/")).trim();\r
+ }\r
+ \r
+ if (line.charAt(0) == '"') {\r
+ line = line.substring(1);\r
+ }\r
+ if (line.charAt(line.length() - 1) == '"') {\r
+ line = line.substring(0, line.length() - 1);\r
}\r
if (inFile) {\r
sb.append("</tbody></table></div>\n");\r
throws IOException {\r
switch (prefix) {\r
case '+':\r
- os.write("<span class=\"diff add\">".getBytes());\r
+ os.write("<span style=\"color:#008000;\">".getBytes());\r
break;\r
case '-':\r
- os.write("<span class=\"diff remove\">".getBytes());\r
+ os.write("<span style=\"color:#800000;\">".getBytes());\r
break;\r
}\r
os.write(prefix);\r
sb.append("<div class=\"diff\">");\r
for (String line : lines) {\r
if (line.startsWith("diff")) {\r
- sb.append("<div class=\"diff header\">").append(line).append("</div>");\r
+ sb.append("<div class=\"diff header\">").append(StringUtils.convertOctal(line)).append("</div>");\r
} else if (line.startsWith("---")) {\r
- sb.append("<span class=\"diff remove\">").append(line).append("</span><br/>");\r
+ sb.append("<span style=\"color:#800000;\">").append(StringUtils.convertOctal(line)).append("</span><br/>");\r
} else if (line.startsWith("+++")) {\r
- sb.append("<span class=\"diff add\">").append(line).append("</span><br/>");\r
+ sb.append("<span style=\"color:#008000;\">").append(StringUtils.convertOctal(line)).append("</span><br/>");\r
} else {\r
sb.append(line).append('\n');\r
}\r
*/\r
package com.gitblit.utils;\r
\r
+import java.io.ByteArrayOutputStream;\r
import java.io.UnsupportedEncodingException;\r
import java.nio.ByteBuffer;\r
import java.nio.CharBuffer;\r
}\r
return url;\r
}\r
+ \r
+ /**\r
+ * Converts a string with \nnn sequences into a UTF-8 encoded string.\r
+ * @param input\r
+ * @return\r
+ */\r
+ public static String convertOctal(String input) {\r
+ try {\r
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();\r
+ Pattern p = Pattern.compile("(\\\\\\d{3})");\r
+ Matcher m = p.matcher(input);\r
+ int i = 0;\r
+ while (m.find()) {\r
+ bytes.write(input.substring(i, m.start()).getBytes("UTF-8"));\r
+ // replace octal encoded value\r
+ // strip leading \ character\r
+ String oct = m.group().substring(1);\r
+ bytes.write(Integer.parseInt(oct, 8));\r
+ i = m.end(); \r
+ }\r
+ if (bytes.size() == 0) {\r
+ // no octal matches\r
+ return input;\r
+ } else {\r
+ if (i < input.length()) {\r
+ // add remainder of string\r
+ bytes.write(input.substring(i).getBytes("UTF-8"));\r
+ }\r
+ }\r
+ return bytes.toString("UTF-8");\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ return input;\r
+ }\r
}
\ No newline at end of file