Commit 060ba9fa authored by Redor's avatar Redor Committed by Dave Cridland

Added UTF-8 support for readme and changelog files

Fixed the issue that creates an empty line after each line of HTML code,
which can break the layout by using <pre>

This patch rewritten to avoid reformatting by Dave Cridland <dave@cridland.net>
parent 65a31a79
...@@ -152,17 +152,17 @@ ...@@ -152,17 +152,17 @@
<% if (showReadme) { <% if (showReadme) {
String pluginName = ParamUtils.getParameter(request, "plugin"); String pluginName = ParamUtils.getParameter(request, "plugin");
Plugin plugin = pluginManager.getPlugin(pluginName); Plugin plugin = pluginManager.getPlugin(pluginName);
StringBuilder readmeString = new StringBuilder();
if (plugin != null) { if (plugin != null) {
File readme = new File(pluginManager.getPluginDirectory(plugin), "readme.html"); File readme = new File(pluginManager.getPluginDirectory(plugin), "readme.html");
if (readme.exists()) { if (readme.exists()) {
BufferedReader in = null; BufferedReader in = null;
try { try {
in = new BufferedReader(new FileReader(readme)); in = new BufferedReader(new InputStreamReader(new FileInputStream(readme), "UTF8"));
String line; String line;
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
%> readmeString.append(line);
<%= line %> readmeString.append(System.getProperty("line.separator"));
<%
} }
} }
catch (IOException ioe) { catch (IOException ioe) {
...@@ -179,23 +179,26 @@ ...@@ -179,23 +179,26 @@
} }
} }
} }
%>
<%=readmeString%>
<%
return; return;
} }
%> %>
<% if (showChangelog) { <% if (showChangelog) {
String pluginName = ParamUtils.getParameter(request, "plugin"); String pluginName = ParamUtils.getParameter(request, "plugin");
Plugin plugin = pluginManager.getPlugin(pluginName); Plugin plugin = pluginManager.getPlugin(pluginName);
StringBuilder changelogString = new StringBuilder();
if (plugin != null) { if (plugin != null) {
File changelog = new File(pluginManager.getPluginDirectory(plugin), "changelog.html"); File changelog = new File(pluginManager.getPluginDirectory(plugin), "changelog.html");
if (changelog.exists()) { if (changelog.exists()) {
BufferedReader in = null; BufferedReader in = null;
try { try {
in = new BufferedReader(new FileReader(changelog)); in = new BufferedReader(new InputStreamReader(new FileInputStream(changelog), "UTF8"));
String line; String line;
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
%> changelogString.append(line);
<%= line %> changelogString.append(System.getProperty("line.separator"));
<%
} }
} }
catch (IOException ioe) { catch (IOException ioe) {
...@@ -212,6 +215,9 @@ ...@@ -212,6 +215,9 @@
} }
} }
} }
%>
<%=changelogString%>
<%
return; return;
} }
%> %>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment