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:
@@ -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 & a <> 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 & a", StringEscapeUtils.escapeHtml("q & a"));
|
||||
assertEquals("q & a <> b", StringEscapeUtils.escapeHtml("q & a <> b"));
|
||||
}
|
||||
|
||||
public void testGetMimeType() {
|
||||
|
||||
Reference in New Issue
Block a user