Use UTF-8 for HTTP Response on Velocity views We need to define UTF-8 encoding on the Velocity views response body. Without this setting the default ISO-8859-1 was used with the inability to encode latin accents or other encoded characters in GitHub full name. Change-Id: I9d33525b035a0675c69581fc39804138ffae763b
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/velocity/VelocityViewServlet.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/velocity/VelocityViewServlet.java index de76a7a..2035f9a 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/velocity/VelocityViewServlet.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/velocity/VelocityViewServlet.java
@@ -14,6 +14,7 @@ package com.googlesource.gerrit.plugins.github.velocity; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Map.Entry; import javax.servlet.ServletException; @@ -90,6 +91,7 @@ VelocityContext context = initVelocityModel(req).getContext(); context.put("request", req); resp.setHeader("content-type", "text/html"); + resp.setCharacterEncoding(StandardCharsets.UTF_8.name()); template.merge(context, resp.getWriter()); } catch (ResourceNotFoundException e) { log.error("Cannot load velocity template " + pathInfo, e);