diff options
-rw-r--r-- | src/test/java/com/gitblit/tests/StringUtilsTest.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/test/java/com/gitblit/tests/StringUtilsTest.java b/src/test/java/com/gitblit/tests/StringUtilsTest.java index b836c71f..cc579888 100644 --- a/src/test/java/com/gitblit/tests/StringUtilsTest.java +++ b/src/test/java/com/gitblit/tests/StringUtilsTest.java @@ -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));
|