Commit 9ca43569 authored by Tom Evans's avatar Tom Evans Committed by tevans

OF-108: Avoid adding <br> tags for newlines in system properties (Peter Johnson)

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13635 b35dd754-fafc-0310-a699-88a17e54d16e
parent 46841a2a
...@@ -263,6 +263,20 @@ public class StringUtils { ...@@ -263,6 +263,20 @@ public class StringUtils {
* with their HTML escape sequences. * with their HTML escape sequences.
*/ */
public static String escapeHTMLTags(String in) { public static String escapeHTMLTags(String in) {
return escapeHTMLTags(in, true);
}
/**
* This method takes a string which may contain HTML tags (ie, &lt;b&gt;,
* &lt;table&gt;, etc) and converts the '&lt'' and '&gt;' characters to
* their HTML escape sequences.
*
* @param in the text to be converted.
* @param includeLF set to true to replace \n with <br>.
* @return the input string with the characters '&lt;' and '&gt;' replaced
* with their HTML escape sequences.
*/
public static String escapeHTMLTags(String in, boolean includeLF) {
if (in == null) { if (in == null) {
return null; return null;
} }
...@@ -290,7 +304,7 @@ public class StringUtils { ...@@ -290,7 +304,7 @@ public class StringUtils {
last = i + 1; last = i + 1;
out.append(GT_ENCODE); out.append(GT_ENCODE);
} }
else if (ch == '\n') { else if (ch == '\n' && includeLF == true) {
if (i > last) { if (i > last) {
out.append(input, last, i - last); out.append(input, last, i - last);
} }
......
...@@ -345,7 +345,7 @@ function dodelete(propName) { ...@@ -345,7 +345,7 @@ function dodelete(propName) {
<fmt:message key="server.properties.value" />: <fmt:message key="server.properties.value" />:
</td> </td>
<td> <td>
<textarea cols="45" rows="5" name="propValue" wrap="virtual"><%= (propValue != null ? StringUtils.escapeHTMLTags(propValue) : "") %></textarea> <textarea cols="45" rows="5" name="propValue" wrap="virtual"><%= (propValue != null ? StringUtils.escapeHTMLTags(propValue, false) : "") %></textarea>
<% if (errors.containsKey("propValue")) { %> <% if (errors.containsKey("propValue")) { %>
......
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