|
|
@@ -61,9 +61,27 @@ public class StringUtilsTest extends GitblitUnitTest { |
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testEscapeForHtml() throws Exception {
|
|
|
|
String input = "& < > \"";
|
|
|
|
String outputNoChange = "& < > "";
|
|
|
|
String outputChange = "& < > "";
|
|
|
|
String input = "\t & < > \"";
|
|
|
|
String outputNoChange = "\t & < > "";
|
|
|
|
String outputChange = " & < > "";
|
|
|
|
assertEquals(outputNoChange, StringUtils.escapeForHtml(input, false));
|
|
|
|
assertEquals(outputChange, StringUtils.escapeForHtml(input, true));
|
|
|
|
|
|
|
|
input = "a\tb";
|
|
|
|
outputNoChange = "a\tb";
|
|
|
|
outputChange = "a b";
|
|
|
|
assertEquals(outputNoChange, StringUtils.escapeForHtml(input, false));
|
|
|
|
assertEquals(outputChange, StringUtils.escapeForHtml(input, true));
|
|
|
|
|
|
|
|
input = "\ta b\t";
|
|
|
|
outputNoChange = "\ta b\t";
|
|
|
|
outputChange = " a b ";
|
|
|
|
assertEquals(outputNoChange, StringUtils.escapeForHtml(input, false));
|
|
|
|
assertEquals(outputChange, StringUtils.escapeForHtml(input, true));
|
|
|
|
|
|
|
|
input = "\t <> \t";
|
|
|
|
outputNoChange = "\t <> \t";
|
|
|
|
outputChange = " <> ";
|
|
|
|
assertEquals(outputNoChange, StringUtils.escapeForHtml(input, false));
|
|
|
|
assertEquals(outputChange, StringUtils.escapeForHtml(input, true));
|
|
|
|
|