docs/03_faq.mkd | ●●●●● patch | view | raw | blame | history | |
docs/04_releases.mkd | ●●●●● patch | view | raw | blame | history | |
src/com/gitblit/utils/GitBlitDiffFormatter.java | ●●●●● patch | view | raw | blame | history | |
src/com/gitblit/utils/GitWebDiffFormatter.java | ●●●●● patch | view | raw | blame | history | |
src/com/gitblit/utils/StringUtils.java | ●●●●● patch | view | raw | blame | history |
docs/03_faq.mkd
@@ -71,6 +71,13 @@ 2. *web.mountParameters = false* and use non-pretty, parameterized urls 3. *web.forwardSlashCharacter = !* which tells Gitblit to use **!** instead of **/** #### UTF-8 Filenames 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. [Tomcat Character Encoding](http://wiki.apache.org/tomcat/FAQ/CharacterEncoding) [Tomcat Connector Properties](http://tomcat.apache.org/tomcat-6.0-doc/config/http.html) ## General Interest Questions ### Gitblit? What kind of name is that? docs/04_releases.mkd
@@ -9,6 +9,14 @@ **%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%* #### fixes - Fixed bug in the diff view for filenames that have non-ASCII characters (issue 128) #### additions - added RedmineUserService (github/mallowlabs) #### changes - 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) src/com/gitblit/utils/GitBlitDiffFormatter.java
@@ -127,15 +127,24 @@ } else if (line.startsWith("---") || line.startsWith("+++")) { // skip --- +++ lines } else if (line.startsWith("diff")) { line = StringUtils.convertOctal(line); if (line.indexOf(oldnull) > -1) { // a is null, use b line = line.substring(("diff --git " + oldnull).length()).trim(); // trim b/ line = line.substring(2); line = line.substring(2).trim(); } else { // use a line = line.substring("diff --git a/".length()).trim(); line = line.substring(0, line.indexOf(" b/")).trim(); line = line.substring("diff --git ".length()).trim(); line = line.substring(line.startsWith("\"a/") ? 3 : 2); line = line.substring(0, line.indexOf(" b/") > -1 ? line.indexOf(" b/") : line.indexOf("\"b/")).trim(); } if (line.charAt(0) == '"') { line = line.substring(1); } if (line.charAt(line.length() - 1) == '"') { line = line.substring(0, line.length() - 1); } if (inFile) { sb.append("</tbody></table></div>\n"); src/com/gitblit/utils/GitWebDiffFormatter.java
@@ -106,10 +106,10 @@ throws IOException { switch (prefix) { case '+': os.write("<span class=\"diff add\">".getBytes()); os.write("<span style=\"color:#008000;\">".getBytes()); break; case '-': os.write("<span class=\"diff remove\">".getBytes()); os.write("<span style=\"color:#800000;\">".getBytes()); break; } os.write(prefix); @@ -140,11 +140,11 @@ sb.append("<div class=\"diff\">"); for (String line : lines) { if (line.startsWith("diff")) { sb.append("<div class=\"diff header\">").append(line).append("</div>"); sb.append("<div class=\"diff header\">").append(StringUtils.convertOctal(line)).append("</div>"); } else if (line.startsWith("---")) { sb.append("<span class=\"diff remove\">").append(line).append("</span><br/>"); sb.append("<span style=\"color:#800000;\">").append(StringUtils.convertOctal(line)).append("</span><br/>"); } else if (line.startsWith("+++")) { sb.append("<span class=\"diff add\">").append(line).append("</span><br/>"); sb.append("<span style=\"color:#008000;\">").append(StringUtils.convertOctal(line)).append("</span><br/>"); } else { sb.append(line).append('\n'); } src/com/gitblit/utils/StringUtils.java
@@ -15,6 +15,7 @@ */ package com.gitblit.utils; import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -624,4 +625,39 @@ } return url; } /** * Converts a string with \nnn sequences into a UTF-8 encoded string. * @param input * @return */ public static String convertOctal(String input) { try { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); Pattern p = Pattern.compile("(\\\\\\d{3})"); Matcher m = p.matcher(input); int i = 0; while (m.find()) { bytes.write(input.substring(i, m.start()).getBytes("UTF-8")); // replace octal encoded value // strip leading \ character String oct = m.group().substring(1); bytes.write(Integer.parseInt(oct, 8)); i = m.end(); } if (bytes.size() == 0) { // no octal matches return input; } else { if (i < input.length()) { // add remainder of string bytes.write(input.substring(i).getBytes("UTF-8")); } } return bytes.toString("UTF-8"); } catch (Exception e) { e.printStackTrace(); } return input; } }