From 86bea9e0016b2890db8ba83049dd4e89653a0a5e Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 16 Mar 2012 17:29:39 -0400 Subject: [PATCH] Ensure that the welcome message is interpreted as UTF-8 (issue 74) --- docs/04_releases.mkd | 2 ++ src/com/gitblit/wicket/pages/RepositoriesPage.java | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd index b2d0c776..f9e4480f 100644 --- a/docs/04_releases.mkd +++ b/docs/04_releases.mkd @@ -30,6 +30,8 @@ Push requests to these repositories will be rejected. #### fixes +- Ensure that Welcome message is parsed using UTF-8 encoding (issue 74) +- Activity page graph layout broken by Google (issue 73) - Uppercase repositories not selectable in edit palettes (issue 71) - Not all git notes were properly displayed on the commit page (issue 70) - Activity page now displays all local branches (issue 65) diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.java b/src/com/gitblit/wicket/pages/RepositoriesPage.java index 07f7ad4c..839f4e34 100644 --- a/src/com/gitblit/wicket/pages/RepositoriesPage.java +++ b/src/com/gitblit/wicket/pages/RepositoriesPage.java @@ -16,7 +16,7 @@ package com.gitblit.wicket.pages; import java.io.File; -import java.io.FileReader; +import java.io.FileInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.text.MessageFormat; @@ -26,6 +26,7 @@ import org.apache.wicket.Component; import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.resource.ContextRelativeResource; +import org.eclipse.jgit.lib.Constants; import com.gitblit.GitBlit; import com.gitblit.Keys; @@ -119,8 +120,11 @@ public class RepositoriesPage extends RootPage { File file = new File(messageSource); if (file.exists()) { try { - FileReader reader = new FileReader(file); + FileInputStream fis = new FileInputStream(file); + InputStreamReader reader = new InputStreamReader(fis, + Constants.CHARACTER_ENCODING); message = MarkdownUtils.transformMarkdown(reader); + reader.close(); } catch (Throwable t) { message = "Failed to read " + file; warn(message, t); @@ -138,7 +142,7 @@ public class RepositoriesPage extends RootPage { try { ContextRelativeResource res = WicketUtils.getResource(file); InputStream is = res.getResourceStream().getInputStream(); - InputStreamReader reader = new InputStreamReader(is); + InputStreamReader reader = new InputStreamReader(is, Constants.CHARACTER_ENCODING); message = MarkdownUtils.transformMarkdown(reader); reader.close(); } catch (Throwable t) { -- 2.39.5