Replace StringUtil.toHtml with StringEscapeUtils.escapeHtml

Apache commons is providing Html-escaping, no need to reinvent the wheel:

> It supports all known HTML 4.0 entities, including funky accents. Note that the
> commonly used apostrophe escape character (') is not a legal entity and so
> is not supported).

So I manually checked that nothing is relying on escaped single-quotes,
and didn't manage to find anything that does.
This commit is contained in:
jvoisin
2019-10-24 21:42:50 +02:00
parent 9dc9cbd821
commit e1583691d8
6 changed files with 20 additions and 68 deletions
@@ -20,6 +20,7 @@
package org.airsonic.player.util;
import junit.framework.TestCase;
import org.apache.commons.lang.StringEscapeUtils;
import java.util.Arrays;
import java.util.Locale;
@@ -32,20 +33,11 @@ import java.util.Locale;
public class StringUtilTestCase extends TestCase {
public void testToHtml() {
assertEquals(null, StringUtil.toHtml(null));
assertEquals("", StringUtil.toHtml(""));
assertEquals(" ", StringUtil.toHtml(" "));
assertEquals("q & a", StringUtil.toHtml("q & a"));
assertEquals("q &amp; a &lt;&gt; b", StringUtil.toHtml("q & a <> b"));
}
public void testRemoveSuffix() {
assertEquals("Error in removeSuffix().", "foo", StringUtil.removeSuffix("foo.mp3"));
assertEquals("Error in removeSuffix().", "", StringUtil.removeSuffix(".mp3"));
assertEquals("Error in removeSuffix().", "foo.bar", StringUtil.removeSuffix("foo.bar.mp3"));
assertEquals("Error in removeSuffix().", "foo.", StringUtil.removeSuffix("foo..mp3"));
assertEquals("Error in removeSuffix().", "foo", StringUtil.removeSuffix("foo"));
assertEquals("Error in removeSuffix().", "", StringUtil.removeSuffix(""));
assertEquals(null, StringEscapeUtils.escapeHtml(null));
assertEquals("", StringEscapeUtils.escapeHtml(""));
assertEquals(" ", StringEscapeUtils.escapeHtml(" "));
assertEquals("q &amp; a", StringEscapeUtils.escapeHtml("q & a"));
assertEquals("q &amp; a &lt;&gt; b", StringEscapeUtils.escapeHtml("q & a <> b"));
}
public void testGetMimeType() {